diff options
author | David Spickett <david.spickett@linaro.org> | 2020-04-21 16:06:08 +0100 |
---|---|---|
committer | David Spickett <david.spickett@linaro.org> | 2020-04-22 13:53:59 +0100 |
commit | 2382c087b5f0d51a4556c8c62f4723ab5a0ab7c9 (patch) | |
tree | 70c781a3087d886dc08a92767b6754991858fd7b | |
parent | 7dac1306e35858ef6485a0abf6222f6e13a28ee0 (diff) |
Various shellcheck warning fixes
First round of low hanging fruit
from the files with the fewest
warnings.
Change-Id: I60ad57b5bfb2f0be9bb6506252c820f44d055200
-rwxr-xr-x | abe-bisect-helper.sh | 3 | ||||
-rwxr-xr-x | abe-bisect.sh | 1 | ||||
-rwxr-xr-x | docker-run.sh | 9 | ||||
-rwxr-xr-x | start-container-docker.sh | 8 | ||||
-rwxr-xr-x | tcwg-benchmark-results.sh | 2 | ||||
-rwxr-xr-x | tcwg-benchmark.sh | 5 | ||||
-rwxr-xr-x | tcwg-cleanup-stale-containers.sh | 3 | ||||
-rwxr-xr-x | tcwg-dev-build.sh | 7 | ||||
-rwxr-xr-x | tcwg-generate-source-cache.sh | 19 | ||||
-rwxr-xr-x | tcwg-llvm-testsuite.sh | 1 | ||||
-rwxr-xr-x | tcwg-start-container.sh | 4 | ||||
-rwxr-xr-x | tcwg-update-llvmbot-containers.sh | 1 | ||||
-rwxr-xr-x | tcwg-update-tested.sh | 4 | ||||
-rwxr-xr-x | tcwg-upstream2gerrit.sh | 5 |
14 files changed, 45 insertions, 27 deletions
diff --git a/abe-bisect-helper.sh b/abe-bisect-helper.sh index db71b10f..ac546f1b 100755 --- a/abe-bisect-helper.sh +++ b/abe-bisect-helper.sh @@ -15,6 +15,7 @@ check_set() { name=$1 + local val eval val=\$${name} [ x$val = x ] && echo $1 not set && exit 1 } @@ -28,7 +29,7 @@ check_set TARGET #check_set SIMU REV=$(git show --format=%H -s BISECT_HEAD) -echo AT `date` BISECT TRYING: ${REV} +echo AT "$(date)" BISECT TRYING: ${REV} git --no-pager show $REV set -x diff --git a/abe-bisect.sh b/abe-bisect.sh index 3764d07b..a933c7d9 100755 --- a/abe-bisect.sh +++ b/abe-bisect.sh @@ -21,6 +21,7 @@ set -x check_set() { name=$1 + local val eval val=\$${name} [ x$val = x ] && echo $1 not set && exit 1 } diff --git a/docker-run.sh b/docker-run.sh index c244829f..ca347447 100755 --- a/docker-run.sh +++ b/docker-run.sh @@ -2,7 +2,7 @@ set -euf -o pipefail -. $(dirname $0)/jenkins-helpers.sh +. "$(dirname $0)"/jenkins-helpers.sh convert_args_to_variables "$@" shift "$SHIFT_CONVERTED_ARGS" @@ -11,11 +11,12 @@ WORKSPACE="${WORKSPACE-}" prefix="${prefix-}" case "$qemu" in - "") $(dirname $0)/start-container-docker.sh "${CONVERTED_ARGS[@]:1}" > container.sh ;; - *) $(dirname $0)/start-container-qemu.sh "${CONVERTED_ARGS[@]:1}" > container.sh ;; + "") "$(dirname $0)"/start-container-docker.sh "${CONVERTED_ARGS[@]:1}" > container.sh ;; + *) "$(dirname $0)"/start-container-qemu.sh "${CONVERTED_ARGS[@]:1}" > container.sh ;; esac # Where prefix is something like "run_" or "test_" +# shellcheck disable=SC2064 trap "${prefix}container_cleanup" EXIT . ./container.sh @@ -27,6 +28,8 @@ if [ "x$WORKSPACE" != "x" ]; then fi JENKINS_FLOCK="flock $WORKSPACE" else + # Used by remote_exec later + # shellcheck disable=SC2034 JENKINS_FLOCK="" fi diff --git a/start-container-docker.sh b/start-container-docker.sh index 3892f999..ff98d563 100755 --- a/start-container-docker.sh +++ b/start-container-docker.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -o pipefail -. $(dirname $0)/jenkins-helpers.sh +. "$(dirname $0)"/jenkins-helpers.sh # Start a local docker instance with the requested arch and distro @@ -26,8 +26,8 @@ usage() { echo " prefix: prefix to prepend to output variables and functions" echo " session-host: hostname where the container will run, defaults to localhost" echo " useful if the name resolution does not work correctly" - echo " session-name: session, in case the default '$BUILD_NUMBER-$JOB_NAME' is not suitable" - echo " ssh_info: set $ssh_host and $ssh_port env variables in the container" + echo " session-name: session, in case the default '\$BUILD_NUMBER-\$JOB_NAME' is not suitable" + echo " ssh_info: set \$ssh_host and \$ssh_port env variables in the container" echo " task: type of container (build, test or bench, default=build)" echo " user: remote user to use in the container." echo " weight: container weight, reserves resources. Default=1" @@ -196,6 +196,7 @@ fi if [ x"$session_name" = x ]; then # Set the default session_name, using BUILD_NUMBER and JOB_NAME, # as set by Jenkins. + # shellcheck disable=SC2153 if [ "x$BUILD_NUMBER" != "x" -a "x$JOB_NAME" != "x" ]; then session_name="$BUILD_NUMBER-$JOB_NAME" else @@ -325,6 +326,7 @@ fi # Remove the docker instance we have just created in case something # goes wrong. CONTAINER_CLEANUP="$DOCKER rm -fv ${session_id}" +# shellcheck disable=SC2064 trap "exec 1>&3 2>&4 ; ${CONTAINER_CLEANUP}" EXIT if [ x"$newuser" != x"" ]; then diff --git a/tcwg-benchmark-results.sh b/tcwg-benchmark-results.sh index 847c0b84..7f7c0e1b 100755 --- a/tcwg-benchmark-results.sh +++ b/tcwg-benchmark-results.sh @@ -13,6 +13,7 @@ obligatory_variables results top_artifacts="${top_artifacts-artifacts}" verbose="${verbose-false}" +# shellcheck disable=SC2154 num_entries_opt="${num_dsos+--num-dsos $num_dsos} ${num_symbols+--num-symbols $num_symbols}" entry_threshold="${entry_threshold-5}" @@ -23,6 +24,7 @@ if $verbose; then fi relative_opt="" +# shellcheck disable=SC2154 if [ x"${results_ref+set}" = x"set" ]; then relative_opt="--relative" results=("$results_ref" "${results[@]}") diff --git a/tcwg-benchmark.sh b/tcwg-benchmark.sh index 9a74eadd..bd41d76b 100755 --- a/tcwg-benchmark.sh +++ b/tcwg-benchmark.sh @@ -8,6 +8,7 @@ set -ex # for empty arguments. bench_container_tag="${bench_container_tag-bionic}" build_container_tag="${build_container_tag-bionic}" +image_arch="$image_arch" toolchain_url="$toolchain_url" toolchain_type="${toolchain_type-auto}" bench_list="$bench_list" @@ -104,7 +105,7 @@ case "$toolchain_url" in # architecture as the machine pointed to by $toolchain_url). # Assume ccprefix looks like /path/bin/target-triplet-, and # compute 'path'. - src_toolchaindir=$(dirname $(dirname ${ccprefix})) + src_toolchaindir=$(dirname "$(dirname ${ccprefix})") toolchaindir="${WORKSPACE}/toolchain-${BUILD_NUMBER}" rsync -az --delete "$src_toolchaindir/" "$toolchaindir/" ;; @@ -156,7 +157,7 @@ case "$toolchain_url" in "llvm") ccname="clang" ;; esac ccpath=$($maybe_remote find "$toolchaindir" -path "*bin/*$ccname") - if [ $(echo "$ccpath" | wc -w) -ne 1 ]; then + if [ "$(echo "$ccpath" | wc -w)" -ne 1 ]; then echo "ERROR: found more than one compiler: $ccpath" exit 1 fi diff --git a/tcwg-cleanup-stale-containers.sh b/tcwg-cleanup-stale-containers.sh index a2d074c8..a0a56943 100755 --- a/tcwg-cleanup-stale-containers.sh +++ b/tcwg-cleanup-stale-containers.sh @@ -85,7 +85,8 @@ do_cleanup_containers () $DOCKER ps $docker_ps_opts local -a rm_containers=() - local curdate=$(date +%s) + local curdate + curdate=$(date +%s) for container in $($DOCKER ps $docker_ps_opts --format "{{.ID}}"); do local container_date container_seconds diff --git a/tcwg-dev-build.sh b/tcwg-dev-build.sh index ff4afacc..d37732a7 100755 --- a/tcwg-dev-build.sh +++ b/tcwg-dev-build.sh @@ -34,13 +34,14 @@ if [ x"$target" = x"native" ]; then manifest_validation_opt="--manifest_validation false" fi +# shellcheck disable=SC2154 $scripts/MakeRelease.job \ - --abedir `pwd`/abe \ - --artifacts_top `pwd`/artifacts \ + --abedir "$(pwd)"/abe \ + --artifacts_top "$(pwd)"/artifacts \ --release_name $release_name \ --target $target \ --toolchainconfig $version \ - --workspace `pwd` \ + --workspace "$(pwd)" \ $manifest_opt \ $manifest_validation_opt \ ${binutils:+--binutils "$binutils"} \ diff --git a/tcwg-generate-source-cache.sh b/tcwg-generate-source-cache.sh index d321724b..10cc9ed9 100755 --- a/tcwg-generate-source-cache.sh +++ b/tcwg-generate-source-cache.sh @@ -72,7 +72,8 @@ generate_abe_snapshots () set -e $verbose - local abe_temp="$(dirname "$0")/abe" + local abe_temp + abe_temp="$(dirname "$0")/abe" rm -rf $abe_temp run_with_timeout_and_retry 10m 3 git clone --branch ${abe_branch} --depth 1 https://git-us.linaro.org/toolchain/abe $abe_temp @@ -153,18 +154,18 @@ update_git_repos () { $verbose local dir="$1" - - for repo_git in $(find "$dir" -name .git -type d); do - ( - local repo - repo=$(dirname "$repo_git") + while IFS= read -r -d '' repo_git + do + ( + local repo + repo=$(dirname "$repo_git") cd "$repo" # Update and prune local clone run_with_timeout_and_retry 1h 3 git remote update -p find -maxdepth 1 ! -name .git ! -name . -print0 \ - | xargs -0 rm -rf - ) - done + | xargs -0 rm -rf + ) + done < <(find "$dir" -name .git -type d -print0) } if $generate_abe; then diff --git a/tcwg-llvm-testsuite.sh b/tcwg-llvm-testsuite.sh index f3931f29..d6bf0cf6 100755 --- a/tcwg-llvm-testsuite.sh +++ b/tcwg-llvm-testsuite.sh @@ -81,6 +81,7 @@ cd "$WORKSPACE" && LC_ALL=C virtualenv --python=$python sandbox |& tee "$LOGBASE cd "$WORKSPACE" && LC_ALL=C "$WORKSPACE/sandbox/bin/python" "$WORKSPACE/lnt/setup.py" develop |& tee "$LOGBASE-setup.$LOGEXT" # Run the test-suite +# shellcheck disable=SC2097,SC2098 cd "$WORKSPACE" && LC_ALL=C CC="$CC" CXX="$CXX" "$WORKSPACE/sandbox/bin/python" \ "$WORKSPACE/sandbox/bin/lnt" runtest nt \ "-j$CPUS" \ diff --git a/tcwg-start-container.sh b/tcwg-start-container.sh index ca7b5d91..008e78c4 100755 --- a/tcwg-start-container.sh +++ b/tcwg-start-container.sh @@ -2,7 +2,7 @@ set -ef -o pipefail -. $(dirname $0)/jenkins-helpers.sh +. "$(dirname $0)"/jenkins-helpers.sh convert_args_to_variables "$@" shift "$SHIFT_CONVERTED_ARGS" @@ -15,8 +15,10 @@ set -u if $verbose; then set -x; fi +# shellcheck disable=SC2154 docker pull "$image" +# shellcheck disable=SC2154 if docker stats --no-stream $container >/dev/null 2>&1; then if $keep_existing; then exit 0 diff --git a/tcwg-update-llvmbot-containers.sh b/tcwg-update-llvmbot-containers.sh index bd7f91fa..7b703410 100755 --- a/tcwg-update-llvmbot-containers.sh +++ b/tcwg-update-llvmbot-containers.sh @@ -47,6 +47,7 @@ for bot in "${bots[@]+${bots[@]}}"; do esac image="linaro/ci-$arch-tcwg-llvmbot-ubuntu:$distro" + # shellcheck disable=SC2154 $scripts/tcwg-start-container.sh \ --container "$master-${bot_prefix}$bot" \ --image "$image" \ diff --git a/tcwg-update-tested.sh b/tcwg-update-tested.sh index a68cabc8..26d75065 100755 --- a/tcwg-update-tested.sh +++ b/tcwg-update-tested.sh @@ -2,7 +2,7 @@ set -ef -o pipefail -. $(dirname $0)/jenkins-helpers.sh +. "$(dirname $0)"/jenkins-helpers.sh convert_args_to_variables "$@" # Make shellcheck happy and workaround Jenkins not defining variables @@ -43,6 +43,6 @@ if [ x"$(git diff HEAD $GIT_COMMIT_2 | wc -l)" != x"0" ]; then rm -rf .git/rebase-merge # Submit review against tcwg-llvmprod branch git review -y tcwg-tested - ssh -p29418 review.linaro.org gerrit review --code-review 2 --submit $(git rev-parse HEAD) + ssh -p29418 review.linaro.org gerrit review --code-review 2 --submit "$(git rev-parse HEAD)" fi popd diff --git a/tcwg-upstream2gerrit.sh b/tcwg-upstream2gerrit.sh index f1fc3fb9..c446b207 100755 --- a/tcwg-upstream2gerrit.sh +++ b/tcwg-upstream2gerrit.sh @@ -2,7 +2,7 @@ set -ef -o pipefail -. $(dirname $0)/jenkins-helpers.sh +. "$(dirname $0)"/jenkins-helpers.sh convert_args_to_variables "$@" # Make shellcheck happy and workaround Jenkins not defining variables @@ -34,7 +34,7 @@ default=$project url= https://patches-$project.linaro.org/xmlrpc/ EOF -last_id=$($pwc list -N 1 -f %{id}) +last_id=$($pwc list -N 1 -f "%{id}") if [ "$last_id" = "" ]; then echo "ERROR: Cannot fetch last patch id." exit 1 @@ -69,6 +69,7 @@ case "$project" in esac patch_file=$(mktemp) +# shellcheck disable=SC2064 trap "rm -f $patch_file /tmp/mydiff.$$" EXIT count="0" |