IVGCVSW-6924 Fix shellcheck warnings

* Fix shellcheck warnings, some have been
  suppressed using shellcheck ignore.

Change-Id: Icae175a42bb348a58befb296949edca51713e977
Signed-off-by: James Conroy <james.conroy@arm.com>
diff --git a/docker/armnn-android/docker-entrypoint.sh b/docker/armnn-android/docker-entrypoint.sh
index 3a82589..b0bf1dc 100644
--- a/docker/armnn-android/docker-entrypoint.sh
+++ b/docker/armnn-android/docker-entrypoint.sh
@@ -67,14 +67,15 @@
 
 # Check Compute Library changes from repo
 cd ${dComputeLib}
-if [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | 
-sed 's/\// /g') | cut -f1) ]
+# shellcheck disable=SC1083
+if [ "$(git rev-parse HEAD)" = "$(git ls-remote "$(git rev-parse --abbrev-ref @{u} |
+sed 's/\// /g')" | cut -f1)" ]
 then
     echo "Compute Lib Up-to-date"
 else 
     echo "New changes are availble for Compute Library repo."
     echo "Do you wanna update (y/n)?"
-    read answer
+    read -r answer
     if [ "$answer" != "${answer#[Yy]}" ] ;then
         updateComputeLib
     fi
@@ -82,8 +83,9 @@
 
 # Check Tensorflow changes from repo
 cd ${dTensorflow}
-if [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | 
-sed 's/\// /g') | cut -f1) ]
+# shellcheck disable=SC1083
+if [ "$(git rev-parse HEAD)" = "$(git ls-remote "$(git rev-parse --abbrev-ref @{u} |
+sed 's/\// /g')" | cut -f1)" ]
 then
     echo "Tensrflow Lib Up-to-date"
 else 
@@ -99,15 +101,16 @@
 
 # Check FlatBuffer changes from repo
 cd ${dFlatBuffer}
-if [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | 
-sed 's/\// /g') | cut -f1) ]
+# shellcheck disable=SC1083
+if [ "$(git rev-parse HEAD)" = "$(git ls-remote "$(git rev-parse --abbrev-ref @{u} |
+sed 's/\// /g')" | cut -f1)" ]
 then
     echo "FlatBuffer Up-to-date"
 else 
     echo "FlatBuffer Not Up-to-date"
     echo "New changes are availble for Compute Library repo."
     echo "Do you wanna update (y/n)?"
-    read answer
+    read -r answer
     if [ "$answer" != "${answer#[Yy]}" ] ;then
         updateFlatBuffer
     fi
diff --git a/profiling/buildpipe.sh b/profiling/buildpipe.sh
index 611b7b9..cacee87 100755
--- a/profiling/buildpipe.sh
+++ b/profiling/buildpipe.sh
@@ -16,10 +16,9 @@
     SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
   fi
 done
-RDIR="$( dirname "$SOURCE" )"
 DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
 
-CMD=$( basename $0 )
+CMD=$( basename "$0" )
 
 usage() {
   echo "Usage: $CMD [options]"
@@ -49,28 +48,32 @@
 
 if [ $CLEAN == 1 ]; then
     echo "removing ${DIR}/build"
-    rm -rf ${DIR}/build
+    rm -rf "${DIR}"/build
 fi
 
 BUILD_DIR="build"
-[ -d build ] || mkdir build
+[ -d build ] || ( mkdir build || exit )
 echo $WINDOWS
 if [ "$WINDOWS" -eq "1" ]; then
     echo "doing windows"
-    cd $BUILD_DIR
+    cd $BUILD_DIR || exit
     [ -d windows ] || mkdir windows
     BUILD_DIR=$BUILD_DIR/windows
-    cd $DIR
+    cd "$DIR" || exit
 fi
 # lower case TYPE in a posix compliant manner
 LC_TYPE=$(echo "$TYPE" | tr '[:upper:]' '[:lower:]')
-if [ ${LC_TYPE} == "debug" ]; then
-    DEBUGDIR=($DIR/$BUILD_DIR/debug)
-    [ -d $DEBUGDIR ] || (cd ${BUILD_DIR} && mkdir debug && cd ..)
+if [ "${LC_TYPE}" == "debug" ]; then
+    DEBUGDIR=("$DIR/$BUILD_DIR/debug")
+    # shellcheck disable=SC2128
+    [ -d "$DEBUGDIR" ] || (cd ${BUILD_DIR} && ( mkdir debug || exit ) && cd ..)
+    # shellcheck disable=SC2128
     BUILD_DIR=$DEBUGDIR
 else
-    RELEASEDIR=($DIR/$BUILD_DIR/release)
-    [ -d $RELEASEDIR ] || (cd ${BUILD_DIR} && mkdir release && cd ..)
+    RELEASEDIR=("$DIR/$BUILD_DIR/release")
+    # shellcheck disable=SC2128
+    [ -d "$RELEASEDIR" ] || (cd "${BUILD_DIR}" && ( mkdir release || exit ) && cd ..)
+    # shellcheck disable=SC2128
     BUILD_DIR=$RELEASEDIR
 fi
 
@@ -84,8 +87,8 @@
     CMARGS="$CMARGS \
            -DCMAKE_TOOLCHAIN_FILE=${DIR}/toolchain-x86-ubuntu-mingw64.cmake"
 fi
-MAKE=make
+MAKE="make"
 
-cd ${BUILD_DIR}
+cd "${BUILD_DIR}" || exit
 pwd
-( eval $CMAKE $CMARGS $DIR && eval ${MAKE} $MAKEFLAGS )
+( eval $CMAKE "$CMARGS" "$DIR" && eval ${MAKE} "$MAKEFLAGS" )
diff --git a/scripts/generate_tensorflow_protobuf.sh b/scripts/generate_tensorflow_protobuf.sh
index 5fd7c6b..b44823f 100755
--- a/scripts/generate_tensorflow_protobuf.sh
+++ b/scripts/generate_tensorflow_protobuf.sh
@@ -24,7 +24,7 @@
   exit 1
 fi
 
-mkdir -p ${OUTPUT_DIR}
+mkdir -p "${OUTPUT_DIR}"
 ERR=$?
 if [ $ERR -ne 0 ]
 then
@@ -54,11 +54,11 @@
 
 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 955b87e..df685cc 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 @@
 }
 
 # 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 @@
   [[ $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 @@
     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 @@
 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 30e7bc6..636dddc 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 @@
 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 @@
   [[ $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 @@
 
 # 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 # 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