From bb5e0da850b1c5ed31cf76af62d91b506c13d8dd Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Wed, 10 Jan 2018 09:37:00 +1000 Subject: [PATCH] Fix ShellCheck v0.4.7 lint issues v0.4.7 introduces some new rules which now need to be handled. Change-Id: If87fceb79e384e26f021a9c85a2e9d7413ce421e Signed-off-by: Anil Belur --- .jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-java-builder | 2 +- .jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-mininet | 2 +- .../expected-xml/gerrit-ciman-packer-merge-ubuntu1604-java-builder | 2 +- .jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-mininet | 2 +- .jjb-test/expected-xml/gerrit-maven-maven-merge-master | 5 +++-- .../gerrit-maven-maven-verify-deps-master-mvn33-openjdk8 | 4 ++-- .jjb-test/expected-xml/gerrit-python-tox-verify-master | 4 ++-- .jjb-test/expected-xml/github-ciman-packer-merge-centos-java-builder | 2 +- .jjb-test/expected-xml/github-ciman-packer-merge-centos-mininet | 2 +- .../expected-xml/github-ciman-packer-merge-ubuntu1604-java-builder | 2 +- .jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-mininet | 2 +- .jjb-test/expected-xml/github-maven-maven-merge-master | 5 +++-- .jjb-test/expected-xml/github-python-tox-verify-master | 4 ++-- ensure-documented.sh | 2 +- shell/gerrit-fetch-dependencies.sh | 2 +- shell/maven-build-deps.sh | 2 +- shell/maven-deploy.sh | 5 +++-- shell/packer-build.sh | 2 +- shell/tox-run.sh | 4 ++-- 19 files changed, 29 insertions(+), 26 deletions(-) diff --git a/.jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-java-builder b/.jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-java-builder index 7888a6cb..2dac4ca8 100644 --- a/.jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-java-builder +++ b/.jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-java-builder @@ -388,7 +388,7 @@ export PACKER_LOG_PATH="$PACKER_BUILD_LOG" && \ "../packer/templates/$PACKER_TEMPLATE.json" # Retrive the list of cloud providers -clouds=($(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json")) +mapfile -t clouds < <(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json") # Split public/private clouds logs for cloud in "${clouds[@]}"; do diff --git a/.jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-mininet b/.jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-mininet index 10091bf3..40b09eff 100644 --- a/.jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-mininet +++ b/.jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-mininet @@ -388,7 +388,7 @@ export PACKER_LOG_PATH="$PACKER_BUILD_LOG" && \ "../packer/templates/$PACKER_TEMPLATE.json" # Retrive the list of cloud providers -clouds=($(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json")) +mapfile -t clouds < <(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json") # Split public/private clouds logs for cloud in "${clouds[@]}"; do diff --git a/.jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-java-builder b/.jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-java-builder index 2aff7534..d1af8b1d 100644 --- a/.jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-java-builder +++ b/.jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-java-builder @@ -388,7 +388,7 @@ export PACKER_LOG_PATH="$PACKER_BUILD_LOG" && \ "../packer/templates/$PACKER_TEMPLATE.json" # Retrive the list of cloud providers -clouds=($(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json")) +mapfile -t clouds < <(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json") # Split public/private clouds logs for cloud in "${clouds[@]}"; do diff --git a/.jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-mininet b/.jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-mininet index 63f727c2..902f52aa 100644 --- a/.jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-mininet +++ b/.jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-mininet @@ -388,7 +388,7 @@ export PACKER_LOG_PATH="$PACKER_BUILD_LOG" && \ "../packer/templates/$PACKER_TEMPLATE.json" # Retrive the list of cloud providers -clouds=($(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json")) +mapfile -t clouds < <(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json") # Split public/private clouds logs for cloud in "${clouds[@]}"; do diff --git a/.jjb-test/expected-xml/gerrit-maven-maven-merge-master b/.jjb-test/expected-xml/gerrit-maven-maven-merge-master index f64dc74a..47b0ba8f 100644 --- a/.jjb-test/expected-xml/gerrit-maven-maven-merge-master +++ b/.jjb-test/expected-xml/gerrit-maven-maven-merge-master @@ -491,8 +491,9 @@ nexus_repo_url="$NEXUS_URL/content/repositories/$NEXUS_REPO" # Remove metadata files that were not updated. set +e # Temporarily disable to run diff command. -metadata_files=($(diff -s -r "$m2repo_dir" "$WORKSPACE/m2repo-backup" \ - | grep 'Files .* and .* are identical' | awk '{print $2}')) +IFS=" " read -r -a metadata_files <<< "$(diff -s -r "$m2repo_dir" "$WORKSPACE/m2repo-backup" \ + | grep 'Files .* and .* are identical' \ + | awk '{print $2}')" set -e # Re-enable. set +u # $metadata_files could be unbound if project is new. diff --git a/.jjb-test/expected-xml/gerrit-maven-maven-verify-deps-master-mvn33-openjdk8 b/.jjb-test/expected-xml/gerrit-maven-maven-verify-deps-master-mvn33-openjdk8 index 107f2cee..13edea68 100644 --- a/.jjb-test/expected-xml/gerrit-maven-maven-verify-deps-master-mvn33-openjdk8 +++ b/.jjb-test/expected-xml/gerrit-maven-maven-verify-deps-master-mvn33-openjdk8 @@ -263,7 +263,7 @@ set -eu -o pipefail REPOS_DIR="$WORKSPACE/.repos" -PATCHES=($(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep 'recheck:' | awk -F: '{print $2}')) +IFS=" " read -r -a PATCHES <<< "$(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep 'recheck:' | awk -F: '{print $2}')" projects=() for patch in $(echo "${PATCHES[@]}"); do @@ -340,7 +340,7 @@ echo "$MAVEN_OPTIONS" set -e -o pipefail set +u -PROJECTS=($(echo "$DEPENDENCY_BUILD_ORDER")) +IFS=" " read -r -a PROJECTS <<< "$DEPENDENCY_BUILD_ORDER" REPOS_DIR="$WORKSPACE/.repos" export MAVEN_OPTS diff --git a/.jjb-test/expected-xml/gerrit-python-tox-verify-master b/.jjb-test/expected-xml/gerrit-python-tox-verify-master index da945ce7..5573a887 100644 --- a/.jjb-test/expected-xml/gerrit-python-tox-verify-master +++ b/.jjb-test/expected-xml/gerrit-python-tox-verify-master @@ -340,7 +340,7 @@ run_tox() { fi } -TOX_ENVS=(${TOX_ENVS//,/ }) +IFS=" " read -r -a TOX_ENVS <<< "${TOX_ENVS//,/ }" if hash parallel 2>/dev/null; then export -f run_tox parallel --jobs 200% "run_tox $ARCHIVE_TOX_DIR {}" ::: ${TOX_ENVS[*]} @@ -351,7 +351,7 @@ else fi if [ -f "$ARCHIVE_TOX_DIR/failed-envs.log" ]; then - failed_envs=($(cat "$ARCHIVE_TOX_DIR/failed-envs.log")) + mapfile -t failed_envs < <(cat "$ARCHIVE_TOX_DIR/failed-envs.log") for e in "${failed_envs[@]}"; do echo "cat $ARCHIVE_TOX_DIR/tox-$e.log" cat "$ARCHIVE_TOX_DIR/tox-$e.log" diff --git a/.jjb-test/expected-xml/github-ciman-packer-merge-centos-java-builder b/.jjb-test/expected-xml/github-ciman-packer-merge-centos-java-builder index 7463d75b..91ba0672 100644 --- a/.jjb-test/expected-xml/github-ciman-packer-merge-centos-java-builder +++ b/.jjb-test/expected-xml/github-ciman-packer-merge-centos-java-builder @@ -346,7 +346,7 @@ export PACKER_LOG_PATH="$PACKER_BUILD_LOG" && \ "../packer/templates/$PACKER_TEMPLATE.json" # Retrive the list of cloud providers -clouds=($(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json")) +mapfile -t clouds < <(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json") # Split public/private clouds logs for cloud in "${clouds[@]}"; do diff --git a/.jjb-test/expected-xml/github-ciman-packer-merge-centos-mininet b/.jjb-test/expected-xml/github-ciman-packer-merge-centos-mininet index a9fbdcc9..18fe98f3 100644 --- a/.jjb-test/expected-xml/github-ciman-packer-merge-centos-mininet +++ b/.jjb-test/expected-xml/github-ciman-packer-merge-centos-mininet @@ -346,7 +346,7 @@ export PACKER_LOG_PATH="$PACKER_BUILD_LOG" && \ "../packer/templates/$PACKER_TEMPLATE.json" # Retrive the list of cloud providers -clouds=($(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json")) +mapfile -t clouds < <(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json") # Split public/private clouds logs for cloud in "${clouds[@]}"; do diff --git a/.jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-java-builder b/.jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-java-builder index 35b4aaa9..146d3423 100644 --- a/.jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-java-builder +++ b/.jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-java-builder @@ -346,7 +346,7 @@ export PACKER_LOG_PATH="$PACKER_BUILD_LOG" && \ "../packer/templates/$PACKER_TEMPLATE.json" # Retrive the list of cloud providers -clouds=($(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json")) +mapfile -t clouds < <(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json") # Split public/private clouds logs for cloud in "${clouds[@]}"; do diff --git a/.jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-mininet b/.jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-mininet index 1bd65add..8870c48d 100644 --- a/.jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-mininet +++ b/.jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-mininet @@ -346,7 +346,7 @@ export PACKER_LOG_PATH="$PACKER_BUILD_LOG" && \ "../packer/templates/$PACKER_TEMPLATE.json" # Retrive the list of cloud providers -clouds=($(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json")) +mapfile -t clouds < <(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json") # Split public/private clouds logs for cloud in "${clouds[@]}"; do diff --git a/.jjb-test/expected-xml/github-maven-maven-merge-master b/.jjb-test/expected-xml/github-maven-maven-merge-master index f5e708cd..47cd9fdb 100644 --- a/.jjb-test/expected-xml/github-maven-maven-merge-master +++ b/.jjb-test/expected-xml/github-maven-maven-merge-master @@ -449,8 +449,9 @@ nexus_repo_url="$NEXUS_URL/content/repositories/$NEXUS_REPO" # Remove metadata files that were not updated. set +e # Temporarily disable to run diff command. -metadata_files=($(diff -s -r "$m2repo_dir" "$WORKSPACE/m2repo-backup" \ - | grep 'Files .* and .* are identical' | awk '{print $2}')) +IFS=" " read -r -a metadata_files <<< "$(diff -s -r "$m2repo_dir" "$WORKSPACE/m2repo-backup" \ + | grep 'Files .* and .* are identical' \ + | awk '{print $2}')" set -e # Re-enable. set +u # $metadata_files could be unbound if project is new. diff --git a/.jjb-test/expected-xml/github-python-tox-verify-master b/.jjb-test/expected-xml/github-python-tox-verify-master index 88b69097..6d758b8c 100644 --- a/.jjb-test/expected-xml/github-python-tox-verify-master +++ b/.jjb-test/expected-xml/github-python-tox-verify-master @@ -302,7 +302,7 @@ run_tox() { fi } -TOX_ENVS=(${TOX_ENVS//,/ }) +IFS=" " read -r -a TOX_ENVS <<< "${TOX_ENVS//,/ }" if hash parallel 2>/dev/null; then export -f run_tox parallel --jobs 200% "run_tox $ARCHIVE_TOX_DIR {}" ::: ${TOX_ENVS[*]} @@ -313,7 +313,7 @@ else fi if [ -f "$ARCHIVE_TOX_DIR/failed-envs.log" ]; then - failed_envs=($(cat "$ARCHIVE_TOX_DIR/failed-envs.log")) + mapfile -t failed_envs < <(cat "$ARCHIVE_TOX_DIR/failed-envs.log") for e in "${failed_envs[@]}"; do echo "cat $ARCHIVE_TOX_DIR/tox-$e.log" cat "$ARCHIVE_TOX_DIR/tox-$e.log" diff --git a/ensure-documented.sh b/ensure-documented.sh index a2ca0721..cab15fcb 100755 --- a/ensure-documented.sh +++ b/ensure-documented.sh @@ -11,7 +11,7 @@ # Checks for JJB documentation interest points and ensures they are documented. -jjb_files=($(find jjb -name "*.yaml")) +mapfile -t jjb_files < <(find jjb -name "*.yaml") undocumented_count=0 for file in "${jjb_files[@]}"; do diff --git a/shell/gerrit-fetch-dependencies.sh b/shell/gerrit-fetch-dependencies.sh index 4870b10e..e9c337c1 100644 --- a/shell/gerrit-fetch-dependencies.sh +++ b/shell/gerrit-fetch-dependencies.sh @@ -22,7 +22,7 @@ set -eu -o pipefail REPOS_DIR="$WORKSPACE/.repos" -PATCHES=($(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep 'recheck:' | awk -F: '{print $2}')) +IFS=" " read -r -a PATCHES <<< "$(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep 'recheck:' | awk -F: '{print $2}')" projects=() for patch in $(echo "${PATCHES[@]}"); do diff --git a/shell/maven-build-deps.sh b/shell/maven-build-deps.sh index bf53bf54..5cf2663c 100644 --- a/shell/maven-build-deps.sh +++ b/shell/maven-build-deps.sh @@ -20,7 +20,7 @@ set -e -o pipefail set +u -PROJECTS=($(echo "$DEPENDENCY_BUILD_ORDER")) +IFS=" " read -r -a PROJECTS <<< "$DEPENDENCY_BUILD_ORDER" REPOS_DIR="$WORKSPACE/.repos" export MAVEN_OPTS diff --git a/shell/maven-deploy.sh b/shell/maven-deploy.sh index fc8e2465..15928eea 100644 --- a/shell/maven-deploy.sh +++ b/shell/maven-deploy.sh @@ -22,8 +22,9 @@ nexus_repo_url="$NEXUS_URL/content/repositories/$NEXUS_REPO" # Remove metadata files that were not updated. set +e # Temporarily disable to run diff command. -metadata_files=($(diff -s -r "$m2repo_dir" "$WORKSPACE/m2repo-backup" \ - | grep 'Files .* and .* are identical' | awk '{print $2}')) +IFS=" " read -r -a metadata_files <<< "$(diff -s -r "$m2repo_dir" "$WORKSPACE/m2repo-backup" \ + | grep 'Files .* and .* are identical' \ + | awk '{print $2}')" set -e # Re-enable. set +u # $metadata_files could be unbound if project is new. diff --git a/shell/packer-build.sh b/shell/packer-build.sh index 714cd33d..e730545d 100644 --- a/shell/packer-build.sh +++ b/shell/packer-build.sh @@ -31,7 +31,7 @@ export PACKER_LOG_PATH="$PACKER_BUILD_LOG" && \ "../packer/templates/$PACKER_TEMPLATE.json" # Retrive the list of cloud providers -clouds=($(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json")) +mapfile -t clouds < <(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json") # Split public/private clouds logs for cloud in "${clouds[@]}"; do diff --git a/shell/tox-run.sh b/shell/tox-run.sh index 45cb1f20..e8172b2b 100644 --- a/shell/tox-run.sh +++ b/shell/tox-run.sh @@ -37,7 +37,7 @@ run_tox() { fi } -TOX_ENVS=(${TOX_ENVS//,/ }) +IFS=" " read -r -a TOX_ENVS <<< "${TOX_ENVS//,/ }" if hash parallel 2>/dev/null; then export -f run_tox parallel --jobs 200% "run_tox $ARCHIVE_TOX_DIR {}" ::: ${TOX_ENVS[*]} @@ -48,7 +48,7 @@ else fi if [ -f "$ARCHIVE_TOX_DIR/failed-envs.log" ]; then - failed_envs=($(cat "$ARCHIVE_TOX_DIR/failed-envs.log")) + mapfile -t failed_envs < <(cat "$ARCHIVE_TOX_DIR/failed-envs.log") for e in "${failed_envs[@]}"; do echo "cat $ARCHIVE_TOX_DIR/tox-$e.log" cat "$ARCHIVE_TOX_DIR/tox-$e.log" -- 2.16.6