[Libguestfs] [PATCH nbdkit 3/4] tests/functions.sh.in: Rename variables $status and $i when running cleanups.

Richard W.M. Jones rjones at redhat.com
Fri May 22 21:32:33 UTC 2020


This causes conflicts if a cleanup hook happens to use a variable with
the same name.
---
 tests/functions.sh.in | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/functions.sh.in b/tests/functions.sh.in
index e2ef9701..b5c7d88b 100644
--- a/tests/functions.sh.in
+++ b/tests/functions.sh.in
@@ -43,17 +43,17 @@ cleanup_fn ()
 
 _run_cleanup_hooks ()
 {
-    local status=$? i
+    local _status=$? _i
 
     set +e
     trap '' INT QUIT TERM EXIT ERR
-    echo $0: run cleanup hooks: exit code $status
+    echo $0: run cleanup hooks: exit code $_status
 
-    for (( i = 0; i < ${#_cleanup_hook[@]}; ++i )); do
-        ${_cleanup_hook[i]}
+    for (( _i = 0; _i < ${#_cleanup_hook[@]}; ++_i )); do
+        ${_cleanup_hook[_i]}
     done
 
-    exit $status
+    exit $_status
 }
 trap _run_cleanup_hooks INT QUIT TERM EXIT ERR
 
-- 
2.25.0




More information about the Libguestfs mailing list