shellcheck: clean up shellcheck warnings and enable
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ibc843b98c0fea97a31d3d15b556a32f091bf8e47
diff --git a/scripts/format-code.sh b/scripts/format-code.sh
index 1bb98a5..4da2174 100755
--- a/scripts/format-code.sh
+++ b/scripts/format-code.sh
@@ -10,7 +10,7 @@
# Input parmameter must be full path to git repo to scan
DIR=$1
-cd ${DIR}
+cd "${DIR}"
set -e
@@ -66,7 +66,7 @@
done
searchfiles=""
-while read path; do
+while read -r path; do
# skip ignorefiles
if [[ $ignorefiles == *"$(basename "${path}")"* ]]; then
continue
@@ -84,12 +84,14 @@
if [ "$skip" = true ]; then
continue
fi
+ # shellcheck disable=2089
searchfiles+="\"./${path}\" "
# Get C and C++ files managed by git and skip the mako files
-done <<<$(git ls-files | grep -e '\.[ch]pp$' -e '\.[ch]$' | grep -v '\.mako\.')
+done <<<"$(git ls-files | grep -e '\.[ch]pp$' -e '\.[ch]$' | grep -v '\.mako\.')"
if [[ -f ".clang-format" ]]; then
+ # shellcheck disable=SC2090 disable=SC2086
echo ${searchfiles} | xargs "${CLANG_FORMAT}" -i
git --no-pager diff --exit-code
fi