[PATCH] tools: fix iterating over argv when recovering xattr

Daniel P. Berrangé berrange at redhat.com
Fri Nov 26 13:38:17 UTC 2021


The libvirt_recover_xattrs.sh tool hangs when run. It appears that
calling 'shift' is not modifying the '$#' value, so the loop never
terminates. Rewrite to just loop over $@ instead which involves less
cleverness.

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 tools/libvirt_recover_xattrs.sh | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tools/libvirt_recover_xattrs.sh b/tools/libvirt_recover_xattrs.sh
index be6ee84b5f..ae9a18bad8 100755
--- a/tools/libvirt_recover_xattrs.sh
+++ b/tools/libvirt_recover_xattrs.sh
@@ -104,11 +104,10 @@ fix_xattrs() {
 }
 
 
-shift $((OPTIND - 1))
 if [ $# -gt 0 ]; then
-    while [ $# -gt 0 ]; do
-        fix_xattrs "$1"
-        shift $((OPTIND - 1))
+    for arg in "$@"
+    do
+        fix_xattrs "$arg"
     done
 else
     if [ ${UNSAFE} -eq 1 ]; then
-- 
2.33.1




More information about the libvir-list mailing list