From e674218dc2caf906310449e4c8aa708f63133f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Fri, 26 Nov 2021 13:36:16 +0000 Subject: [PATCH] tools: fix iterating over argv when recovering xattr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é --- 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