test/system: Limit the scope of the loop counters to the functions

This should prevent these functions from overwriting variables of the
same name beyond the function and causing hard-to-debug problems [1].

[1] Bats commit 502dc47dd063c187
    https://github.com/bats-core/bats-core/commit/502dc47dd063c187
    https://github.com/bats-core/bats-core/issues/726

https://github.com/containers/toolbox/pull/1373
This commit is contained in:
Debarshi Ray 2023-09-21 19:51:46 +02:00
parent 8f6e47a191
commit 12da2b845f

View file

@ -107,6 +107,8 @@ function _pull_and_cache_distro_image() {
assert_success assert_success
fi fi
local -i j
for ((j = 0; j < num_of_retries; j++)); do for ((j = 0; j < num_of_retries; j++)); do
run "$SKOPEO" copy --dest-compress "docker://${image}" "dir:${IMAGE_CACHE_DIR}/${image_archive}" run "$SKOPEO" copy --dest-compress "docker://${image}" "dir:${IMAGE_CACHE_DIR}/${image_archive}"
@ -439,6 +441,7 @@ function container_started() {
# Used as a return value # Used as a return value
container_initialized=1 container_initialized=1
local -i j
local num_of_retries=5 local num_of_retries=5
for ((j = 0; j < num_of_retries; j++)); do for ((j = 0; j < num_of_retries; j++)); do