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

Martin Kletzander mkletzan at redhat.com
Mon Nov 29 15:40:44 UTC 2021


On Fri, Nov 26, 2021 at 03:46:56PM +0000, Daniel P. Berrangé wrote:
>The libvirt_recover_xattrs.sh tool hangs when run. When not flags

s/not/no/

>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>

Reviewed-by: Martin Kletzander <mkletzan 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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20211129/56ef69ad/attachment-0001.sig>


More information about the libvir-list mailing list