From f36db7e20726255be58ea7331922e047bda27e73 Mon Sep 17 00:00:00 2001 From: Don Penney Date: Tue, 11 Aug 2020 10:36:43 -0400 Subject: [PATCH] Fix use of 'let -i' in scripts Unlike "declare -i" and "local -i", the bash "let" does not support a "-i" option. Rather, it takes it as a variable reference. If no "i" variable is defined in scope, it does not cause an issue. If "i" has been defined somewhere, however, it may cause a syntax issue, as the i is evaluated. A recent update to build-stx-images.sh added a loop that defines an "i" variable without limiting its scope. In a current image build, this loop ends with having "i" defined as a URL. As a result, a "syntax error in expression" occurs, causing the "with_retries" function to fail to increment the counter. Should a build error occur, the "with_retries" will never hit the retry limit, looping until it has a successful result. This update removes the -i from all "let -i" occurrences in the build scripts. Change-Id: I34ad49f8872a81659ff4caf8087b256ea9fb3d32 Closes-Bug: 1891189 Signed-off-by: Don Penney --- build-tools/build-wheels/docker/docker-build-wheel.sh | 4 ++-- build-tools/build-wheels/utils.sh | 2 +- build-tools/patch-iso | 2 +- build-tools/srpm-utils | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build-tools/build-wheels/docker/docker-build-wheel.sh b/build-tools/build-wheels/docker/docker-build-wheel.sh index 17ee90a0..9da8b84f 100755 --- a/build-tools/build-wheels/docker/docker-build-wheel.sh +++ b/build-tools/build-wheels/docker/docker-build-wheel.sh @@ -117,7 +117,7 @@ function with_retries { local -i attempt=0 while :; do - let -i attempt++ + let attempt++ echo "Running: ${cmd} $@" ${cmd} "$@" @@ -340,7 +340,7 @@ from_zip from_pypi if [ -f $FAILED_LOG ]; then - let -i failures=$(cat $FAILED_LOG | wc -l) + let failures=$(cat $FAILED_LOG | wc -l) cat <&/dev/null if [ $? -ne 0 ]; then echo "Unable to find required utility: ${req}" >&2 - let -i missing++ + let missing++ fi done diff --git a/build-tools/srpm-utils b/build-tools/srpm-utils index a424b8d8..8160856b 100644 --- a/build-tools/srpm-utils +++ b/build-tools/srpm-utils @@ -206,7 +206,7 @@ srpm_create_raw_extract_script () { SAME=1 fi - let -i COUNT=0 + let COUNT=0 while [ $SAME -eq 0 ]; do \cp -f $STDOUT_LOG $PREV_STDOUT_LOG \cp -f $STDERR_LOG $PREV_STDERR_LOG @@ -226,7 +226,7 @@ srpm_create_raw_extract_script () { if [ $? -eq 0 ]; then SAME=1 fi - let -i COUNT++ + let COUNT++ if [ $COUNT -ge 20 ]; then break; fi