]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tools: fix iterating over argv when recovering xattr
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 26 Nov 2021 13:36:16 +0000 (13:36 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 30 Nov 2021 10:45:35 +0000 (10:45 +0000)
The libvirt_recover_xattrs.sh tool hangs when run. When no flags
are provided OPTIND is 1, so the loop expands to 'shift 0' which
has not effect. Rewrite to just loop over $@ instead which involves
less cleverness.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
tools/libvirt_recover_xattrs.sh

index be6ee84b5f4102d66f7d87294a3979f521b6920b..35c164a9c76f45db0ee3d06fc0a4cd1705bba64b 100755 (executable)
@@ -106,9 +106,9 @@ 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