From: Guillaume Lambert Date: Tue, 4 May 2021 08:14:24 +0000 (+0200) Subject: Fix: bashate E043 warnings X-Git-Tag: v0.63.1~5 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=f1965ead65dbec24eafddcd6e59c793406a4c099;p=releng%2Fglobal-jjb.git Fix: bashate E043 warnings Arithmetic compound has inconsistent return semantics ((expr)) has a trap that if expr is 0, the return value is 1. This will trigger a failure with "set -e" and can be very confusing. It is good defensive programming to avoid this with explicit assignment. Signed-off-by: Guillaume Lambert Change-Id: I412bd8872560c90c28642ed5433eab9b2a29a5e8 --- diff --git a/ensure-documented.sh b/ensure-documented.sh index 823a542a..bc1077d5 100755 --- a/ensure-documented.sh +++ b/ensure-documented.sh @@ -30,7 +30,7 @@ for file in "${jjb_files[@]}"; do for item in "${docs_interests[@]}"; do if ! grep -q "$item" "docs/${file//.yaml/.rst}"; then echo "$file:$item" - (( undocumented_count++ )) + undocumented_count=$((undocumented_count+1)) fi done done diff --git a/shell/job-cost.sh b/shell/job-cost.sh index dde31298..4648a953 100644 --- a/shell/job-cost.sh +++ b/shell/job-cost.sh @@ -53,9 +53,8 @@ else fi # Retrieve the current uptime (in seconds) -uptime=$(awk '{print $1}' /proc/uptime) -# Convert to integer by truncating fractional part' and round up by one -((uptime=${uptime%\.*}+1)) +# And Convert to integer by truncating fractional part' and round up by one +uptime=$(awk '{print int($1 + 1)}' /proc/uptime) # EC2 and OpenStack have simiar instace metadata APIs at this IP # AWS docs: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html diff --git a/shell/rtdv3.sh b/shell/rtdv3.sh index 08f98a29..eb229b33 100644 --- a/shell/rtdv3.sh +++ b/shell/rtdv3.sh @@ -83,7 +83,7 @@ echo "INFO: Performing merge action" fi echo "INFO sleeping for 30 seconds $cnt times" sleep 30 - ((cnt+=1)) + cnt=$((cnt+1)) if (( cnt >= 20 )); then echo "INFO: Job has timed out" exit 1