diff options
author | David Spickett <david.spickett@linaro.org> | 2020-04-20 15:43:57 +0100 |
---|---|---|
committer | David Spickett <david.spickett@linaro.org> | 2020-04-20 16:58:38 +0100 |
commit | b9ecc76e09e95cd3132f1eef572279c1cec68218 (patch) | |
tree | 926c2b2d6d411ad266f70ee2756083bbbe07c05c | |
parent | 5bc4a8aa4bb4ec6ffc77d0acce0e3370582760d6 (diff) |
Shellcheck warning fixes
(all error/style level warnings)
SC1035: missing whitespace
SC2068: double quote array expansions
SC2145: argument mixes string and array
SC1066: Don't use $ on the left side of assignments
SC2126: Use grep -c instead of grep|wc
Change-Id: Ia53070d3e2c9aea9f626fdb7b2b5bfc9e1f8e682
-rwxr-xr-x | abe-bisect-helper.sh | 4 | ||||
-rwxr-xr-x | abe-bisect.sh | 8 | ||||
-rw-r--r-- | jenkins-helpers.sh | 22 | ||||
-rw-r--r-- | round-robin.sh | 2 | ||||
-rwxr-xr-x | tcwg-cleanup-stale-containers.sh | 2 | ||||
-rwxr-xr-x | tcwg-llvm-common.sh | 4 | ||||
-rwxr-xr-x | tcwg_bmk-build.sh | 4 |
7 files changed, 23 insertions, 23 deletions
diff --git a/abe-bisect-helper.sh b/abe-bisect-helper.sh index 9eea24ef..db71b10f 100755 --- a/abe-bisect-helper.sh +++ b/abe-bisect-helper.sh @@ -56,10 +56,10 @@ ${ABE}/abe.sh --target ${TARGET} \ [ $? -ne 0 ] && exit 125 sums=`find builds/*/${TARGET}/gcc.git~master_rev_${REV}-stage2/ -name "*.sum"` -nb_fail=$(grep -w FAIL $sums | wc -l) +nb_fail=$(grep -wc FAIL $sums) [ ${nb_fail} -gt ${GOODFAIL} ] && exit 1 # More failures than GOOD, this is a bad one -nb_pass=$(grep -w PASS $sums | wc -l) +nb_pass=$(grep -wc PASS $sums) [ ${nb_pass} -ge ${GOODPASS} ] && exit 0 # At least as many passes as GOOD, this is a good one exit 125 # something went wrong diff --git a/abe-bisect.sh b/abe-bisect.sh index ecf551f4..3764d07b 100755 --- a/abe-bisect.sh +++ b/abe-bisect.sh @@ -104,8 +104,8 @@ if [ $? -ne 0 ]; then fi sums=`find builds/*/${TARGET}/gcc.git~master_rev_${GOODSHA1}-stage2/ -name "*.sum"` -good_nb_fail=$(grep -w FAIL $sums | wc -l) -good_nb_pass=$(grep -w PASS $sums | wc -l) +good_nb_fail=$(grep -wc FAIL $sums) +good_nb_pass=$(grep -wc PASS $sums) ${ABE}/abe.sh --target ${TARGET} \ gcc=gcc.git@${BADSHA1} \ @@ -120,8 +120,8 @@ if [ $? -ne 0 ]; then fi sums=`find builds/*/${TARGET}/gcc.git~master_rev_${BADSHA1}-stage2/ -name "*.sum"` -bad_nb_fail=$(grep -w FAIL $sums | wc -l) -bad_nb_pass=$(grep -w PASS $sums | wc -l) +bad_nb_fail=$(grep -wc FAIL $sums) +bad_nb_pass=$(grep -wc PASS $sums) # make sure BAD has more failures than GOOD if [ $bad_nb_fail -le $good_nb_fail ]; then diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh index aea10d88..3c0bd7a0 100644 --- a/jenkins-helpers.sh +++ b/jenkins-helpers.sh @@ -271,7 +271,7 @@ remote_exec () # E.g., when triggering jobs via jenkins-cli, the command is not a binary, # so we can't "exec" it. # We use flock if $JENKINS_FLOCK is set. - ${JENKINS_FLOCK+$JENKINS_FLOCK} ssh $opts ${port:+-p$port} $host "${env_vars:+export $env_vars && }${dir:+cd "$(printf '%q' "$dir")" && exec }${cmd[@]}" + ${JENKINS_FLOCK+$JENKINS_FLOCK} ssh $opts ${port:+-p$port} $host "${env_vars:+export $env_vars && }${dir:+cd "$(printf '%q' "$dir")" && exec }${cmd[*]}" ) } @@ -874,9 +874,9 @@ convert_args_to_variables () ;; "--"*) name="${1#--}" - declare -g $name="$2" + declare -g "$name=$2" cat <<EOF | manifest_out -declare -g $name="$2" +declare -g "$name=$2" EOF num=2 ;; @@ -1220,15 +1220,15 @@ run_step () case "$run_step_status:$run_mode" in 0:*) ;; *:stop_on_fail) - echo "STOPPING before ${step[@]} due to previous failure" + echo "STOPPING before ${step[*]} due to previous failure" false ;; *:skip_on_fail) - echo "SKIPPING ${step[@]} due to previous failure" + echo "SKIPPING ${step[*]} due to previous failure" skip=true ;; *:reset_on_fail) - echo "HANDLING previous failure in ${step[@]}" + echo "HANDLING previous failure in ${step[*]}" ;; *) assert false @@ -1240,26 +1240,26 @@ run_step () rm -rf "$run_step_artifacts" mkdir -p "$run_step_artifacts" - echo "RUNNING ${step[@]}; see tail -f $run_step_artifacts/console.log" + echo "RUNNING ${step[*]}; see tail -f $run_step_artifacts/console.log" run_step_status=0 - eval "if $run_step_verbose; then set -x; else set +x; fi; ${step[@]}" 2>&1 | ts -s "%T" | tee -a $run_step_top_artifacts/console.log > $run_step_artifacts/console.log & + eval "if $run_step_verbose; then set -x; else set +x; fi; ${step[*]}" 2>&1 | ts -s "%T" | tee -a $run_step_top_artifacts/console.log > $run_step_artifacts/console.log & wait $! || run_step_status=$? case "$run_step_status:$run_mode" in 0:*) ;; *:stop_on_fail|*:reset_on_fail) - echo "STOPPING at ${step[@]} due to failure" + echo "STOPPING at ${step[*]} due to failure" false ;; *:skip_on_fail) - echo "CARRYING ON after failure in ${step[@]}" + echo "CARRYING ON after failure in ${step[*]}" ;; *) assert false esac fi else - echo "SKIPPING ${step[@]}" + echo "SKIPPING ${step[*]}" fi if [ x"$run_step_status" = x"0" -a x"$success_result" != x"x" ]; then diff --git a/round-robin.sh b/round-robin.sh index d21d876b..242c81b7 100644 --- a/round-robin.sh +++ b/round-robin.sh @@ -359,7 +359,7 @@ build_abe () # Remove previous build directories and .stamp files. # We rely on ccache for fast rebuilds. - if [ !$check ]; then + if [ ! $check ]; then set +f; rm -rf builds/*/*/$git_dir*; set -f fi diff --git a/tcwg-cleanup-stale-containers.sh b/tcwg-cleanup-stale-containers.sh index 97d8e1ba..a2d074c8 100755 --- a/tcwg-cleanup-stale-containers.sh +++ b/tcwg-cleanup-stale-containers.sh @@ -115,7 +115,7 @@ do_cleanup_containers () local res local status="0" if [ ${#rm_containers[@]} != 0 ]; then - echo "Containers to ${action_msg}: ${rm_containers[@]}" + echo "Containers to ${action_msg}: ${rm_containers[*]}" if $cleanup_containers; then for container in "${rm_containers[@]}"; do echo "Container to ${action_msg}: $container" diff --git a/tcwg-llvm-common.sh b/tcwg-llvm-common.sh index c9ef4140..521d2c12 100755 --- a/tcwg-llvm-common.sh +++ b/tcwg-llvm-common.sh @@ -101,7 +101,7 @@ find_svn_rev() { # Find the largest revision of a list find_last_rev() { local LAST=0 - for rev in $@; do + for rev in "$@"; do [ "$rev" -gt "$LAST" ] && LAST=$rev done echo "$LAST" @@ -123,7 +123,7 @@ has_remote_branch() { is_in_list() { local ITEM="$1" shift - for item in $@; do + for item in "$@"; do if [ "$ITEM" = "$item" ]; then return 0 fi diff --git a/tcwg_bmk-build.sh b/tcwg_bmk-build.sh index 6f7d846f..6143ae6b 100755 --- a/tcwg_bmk-build.sh +++ b/tcwg_bmk-build.sh @@ -26,7 +26,7 @@ EOF rr[toolchain]=${rr[toolchain]-${ci_config[0]}} rr[target]=${rr[target]-${ci_config[2]}} benchmarks=("${benchmarks[@]-${ci_config[3]}}") -if [ ${#benchmarks[@]} = 1 ] && [ x"${benchmarks[@]}" = x"default" ]; then +if [ x"${benchmarks[*]}" = x"default" ]; then benchmarks=("${ci_config[3]}") fi if ! test_array cflags; then @@ -410,7 +410,7 @@ no_regression_vs_p () fi fi done < <(tail -n +2 $run_step_artifacts/results-compare.csv) - echo "extra_build_params=${bisect_bmks[@]}" > $run_step_artifacts/extra-bisect-params + echo "extra_build_params=${bisect_bmks[*]}" > $run_step_artifacts/extra-bisect-params return $status ) } |