scripts: format-code.sh: use double braces
Use double braces in format-code.sh
[[ ... ]] reduces errors as no pathname expansion or word splitting
takes place between [[ and ]]. In addition, [[ ... ]] allows for
regular expression matching while [ ... ] does not.
Change-Id: Ie74e625edd8b3f6f9b4c4ec2a9dce14983c73643
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/scripts/format-code.sh b/scripts/format-code.sh
index e5a68a5..9b63910 100755
--- a/scripts/format-code.sh
+++ b/scripts/format-code.sh
@@ -16,10 +16,10 @@
echo "Formatting code under $DIR/"
-if [ -f "setup.cfg" ]; then
+if [[ -f "setup.cfg" ]]; then
pycodestyle --show-source .
rc=$?
- if [ ${rc} -ne 0 ]; then
+ if [[ ${rc} -ne 0 ]]; then
exit ${rc}
fi
fi
@@ -27,7 +27,7 @@
# Allow called scripts to know which clang format we are using
export CLANG_FORMAT="clang-format-6.0"
-if [ -f ".clang-format" ]; then
+if [[ -f ".clang-format" ]]; then
find . -regextype sed -regex ".*\.[hc]\(pp\)\?" -not -name "*mako*" -print0 |\
xargs -0 "${CLANG_FORMAT}" -i
git --no-pager diff --exit-code
@@ -35,7 +35,7 @@
# Sometimes your situation is terrible enough that you need the flexibility.
# For example, phosphor-mboxd.
-if [ -f "format-code.sh" ]; then
+if [[ -f "format-code.sh" ]]; then
./format-code.sh
git --no-pager diff --exit-code
fi