From: Daniel P. Berrangé Date: Fri, 26 Nov 2021 13:36:16 +0000 (+0000) Subject: tools: fix iterating over argv when recovering xattr X-Git-Tag: v7.10.0~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e674218dc2caf906310449e4c8aa708f63133f03;p=thirdparty%2Flibvirt.git tools: fix iterating over argv when recovering xattr 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 Signed-off-by: Daniel P. Berrangé --- 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