summaryrefslogtreecommitdiff
path: root/tools/ci/jobs/cpplint.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ci/jobs/cpplint.sh')
-rwxr-xr-xtools/ci/jobs/cpplint.sh22
1 files changed, 13 insertions, 9 deletions
diff --git a/tools/ci/jobs/cpplint.sh b/tools/ci/jobs/cpplint.sh
index b51694b3b..fd73705dc 100755
--- a/tools/ci/jobs/cpplint.sh
+++ b/tools/ci/jobs/cpplint.sh
@@ -1,7 +1,9 @@
#!/usr/bin/env bash
-export LOGFILE=cpplint.log
+set -e # Fail if any command fails
+set -u # Fail if any variable is unset when used
+export LOGFILE=cpplint.log
source ./tools/ci/scripts/init.sh
# Re-download if not executable or older than a day
@@ -45,16 +47,18 @@ args+=("--filter=\
find src \
-type f \
-name "*.cpp" -o -name "*.hpp" -o -name "*.h" -o -name "*.cc" \
- -exec ./cpplint.py "${args[@]}" {} \+ 2>${ERRFILE}2
+ -exec ./cpplint.py "${args[@]}" {} \+ 2>"$ERRFILE_UNFILTERED" \
+ || { cat "$ERRFILE_UNFILTERED"; exit 1; }
-grep ": " ${ERRFILE}2 | grep -v -e "src/debug/" \
- -e "unittests/doctest.h" \
- -e "unittests/catch.hpp" \
- -e "debug/fast_mutex" \
- -e "sdl2gfx/SDL2" \
- >${ERRFILE}
+# if grep does not find any messages, it exits non-zero
+grep ": " "$ERRFILE_UNFILTERED" \
+ | grep -v -e "src/debug/" \
+ -e "unittests/doctest.h" \
+ -e "unittests/catch.hpp" \
+ -e "debug/fast_mutex" \
+ -e "sdl2gfx/SDL2" \
+ >${ERRFILE} || true
-rm ${ERRFILE}2
run_check_warnings