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

Daniel P. Berrangé berrange at redhat.com
Fri Nov 26 15:46:56 UTC 2021


The libvirt_recover_xattrs.sh tool hangs when run. When not 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.

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

diff --git a/tools/libvirt_recover_xattrs.sh b/tools/libvirt_recover_xattrs.sh
index be6ee84b5f..35c164a9c7 100755
--- a/tools/libvirt_recover_xattrs.sh
+++ b/tools/libvirt_recover_xattrs.sh
@@ -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
-- 
2.33.1




More information about the libvir-list mailing list