From 04cd60384f5fc8455bb7cf64416daa7b001754d1 Mon Sep 17 00:00:00 2001 From: James Conroy Date: Wed, 20 Apr 2022 17:16:50 +0100 Subject: IVGCVSW-6924 Fix shellcheck warnings * Fix shellcheck warnings, some have been suppressed using shellcheck ignore. Change-Id: Icae175a42bb348a58befb296949edca51713e977 Signed-off-by: James Conroy --- scripts/generate_tensorflow_protobuf.sh | 8 ++++---- scripts/get_compute_library.sh | 15 ++++++++------- scripts/get_tensorflow.sh | 14 +++++++------- 3 files changed, 19 insertions(+), 18 deletions(-) (limited to 'scripts') diff --git a/scripts/generate_tensorflow_protobuf.sh b/scripts/generate_tensorflow_protobuf.sh index 5fd7c6b4b1..b44823f1dd 100755 --- a/scripts/generate_tensorflow_protobuf.sh +++ b/scripts/generate_tensorflow_protobuf.sh @@ -24,7 +24,7 @@ then exit 1 fi -mkdir -p ${OUTPUT_DIR} +mkdir -p "${OUTPUT_DIR}" ERR=$? if [ $ERR -ne 0 ] then @@ -54,11 +54,11 @@ fi OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH #hardware_types.proto and autotuning.proto not required -find tensorflow -type f -name '*.proto' | grep -v autotuning | grep -v hardware_types | while read i; do - LD_LIBRARY_PATH=$OLD_LD_LIBRARY_PATH:${PROTOBUF_INSTALL_DIR}/lib $PROTOBUF_INSTALL_DIR/bin/protoc $i \ +find tensorflow -type f -name '*.proto' | grep -v autotuning | grep -v hardware_types | while read -r i; do + LD_LIBRARY_PATH=$OLD_LD_LIBRARY_PATH:${PROTOBUF_INSTALL_DIR}/lib $PROTOBUF_INSTALL_DIR/bin/protoc "$i" \ --proto_path=. \ --proto_path=${PROTOBUF_INSTALL_DIR}/include \ - --cpp_out $OUTPUT_DIR + --cpp_out "$OUTPUT_DIR" EXIT_CODE=$? if [ $EXIT_CODE -ne 0 ]; then echo "Failed to make proto files" diff --git a/scripts/get_compute_library.sh b/scripts/get_compute_library.sh index 955b87efca..df685cca1a 100755 --- a/scripts/get_compute_library.sh +++ b/scripts/get_compute_library.sh @@ -4,7 +4,7 @@ # SPDX-License-Identifier: MIT # -CMD=$( basename $0 ) +CMD=$( basename "$0" ) # For pinning to a ref use this: #DEFAULT_CLFRAMEWORKREVISION="branches/arm_compute_22_02" # Release 22.02 @@ -34,11 +34,10 @@ function AssertZeroExitCode { } # process the options given -while getopts "s:phg:" opt; do +while getopts "s:ph" opt; do case "$opt" in s) CLFRAMEWORK_SHA="$OPTARG";; p) PrintDefaultClframeworkSha;; - g) DUMMY="$OPTARG";; # continue to accept -g for backward compatibility h|\?) usage;; esac done @@ -59,7 +58,8 @@ while [ -h "$SRC" ]; do [[ $SRC != /* ]] && SRC="$DIR/$SRC" done DIR="$( cd -P "$( dirname "$SRC" )" >/dev/null && pwd )" -pushd ${DIR} > /dev/null +pushd "${DIR}" > /dev/null +# shellcheck disable=SC2164 cd ../.. if [ ! -d clframework ]; then @@ -73,7 +73,7 @@ if [ ! -z "$CLFRAMEWORK_SHA" ]; then CLFRAMEWORKREVISION=$CLFRAMEWORK_SHA fi -git fetch && git fetch https://review.mlplatform.org/ml/ComputeLibrary && git checkout ${CLFRAMEWORKREVISION} +git fetch && git fetch https://review.mlplatform.org/ml/ComputeLibrary && git checkout "${CLFRAMEWORKREVISION}" AssertZeroExitCode "Fetching and checking out ${CLFRAMEWORKREVISION} failed" # If the target ACL revision includes a branch we also need to do a pull. # This generally occurs with a release branch. @@ -83,12 +83,13 @@ if [[ "${CLFRAMEWORKREVISION}" == *"branches"* ]]; then fi # Set commit hook so we can submit reviews to gerrit -(curl -Lo `git rev-parse --git-dir`/hooks/commit-msg https://review.mlplatform.org/tools/hooks/commit-msg; chmod +x `git rev-parse --git-dir`/hooks/commit-msg) +# shellcheck disable=SC2006 +(curl -Lo "$(git rev-parse --git-dir)"/hooks/commit-msg https://review.mlplatform.org/tools/hooks/commit-msg; chmod +x "$(git rev-parse --git-dir)"/hooks/commit-msg) AssertZeroExitCode "Setting commit hooks failed" popd > /dev/null # out of clframework popd > /dev/null # back to wherever we were when called # Make sure the SHA of the revision that was checked out is the last line # of output from the script... just in case we ever need it. -echo $CLFRAMEWORKREVISION +echo "$CLFRAMEWORKREVISION" exit 0 diff --git a/scripts/get_tensorflow.sh b/scripts/get_tensorflow.sh index 30e7bc6c3c..636dddcaf4 100755 --- a/scripts/get_tensorflow.sh +++ b/scripts/get_tensorflow.sh @@ -5,7 +5,7 @@ # SPDX-License-Identifier: MIT # -CMD=$( basename $0 ) +CMD=$( basename "$0" ) # Revision or tag that Arm NN has been tested with: DEFAULT_TENSORFLOW_REVISION="tags/v2.5.0" # Release 2.5.0 tag @@ -38,11 +38,11 @@ function AssertZeroExitCode { TENSORFLOW_REVISION=$DEFAULT_TENSORFLOW_REVISION # process the options given -while getopts "s:ph\?:" opt; do +while getopts "s:ph" opt; do case "$opt" in s) TENSORFLOW_REVISION="$OPTARG";; p) PrintDefaultTensorFlowSha;; - h|\?) Usage;; + h) Usage;; esac done shift $((OPTIND - 1)) @@ -62,8 +62,8 @@ while [ -h "$SRC" ]; do [[ $SRC != /* ]] && SRC="$DIR/$SRC" done DIR="$( cd -P "$( dirname "$SRC" )" >/dev/null && pwd )" -pushd ${DIR} > /dev/null -cd ../.. +pushd "${DIR}" > /dev/null +cd ../.. || exit # Clone TensorFlow if we don't already have a directory if [ ! -d tensorflow ]; then @@ -75,7 +75,7 @@ pushd tensorflow > /dev/null # Checkout the TensorFlow revision echo "Checking out ${TENSORFLOW_REVISION}" -git fetch && git checkout ${TENSORFLOW_REVISION} +git fetch && git checkout "${TENSORFLOW_REVISION}" AssertZeroExitCode "Fetching and checking out ${TENSORFLOW_REVISION} failed" # If the target tensorflow revision includes a branch we also need to do a pull. # This generally occurs with a release branch. @@ -88,5 +88,5 @@ popd > /dev/null # out of tensorflow popd > /dev/null # back to wherever we were when called # Make sure the SHA of the revision that was checked out is the last line # of output from the script... just in case we ever need it. -echo $TENSORFLOW_REVISION +echo "$TENSORFLOW_REVISION" exit 0 -- cgit v1.2.1