From 3de83322e5d2a6cd6b23d2ba1197f1a11d357842 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 5 Apr 2022 13:17:00 -0500 Subject: [PATCH] Add shellcheck wrapper script Signed-off-by: Michael Richters --- Makefile | 8 +------- bin/check-shell-scripts.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) create mode 100755 bin/check-shell-scripts.sh diff --git a/Makefile b/Makefile index 5f8716e7..bcfb2560 100644 --- a/Makefile +++ b/Makefile @@ -123,14 +123,8 @@ cpplint-noisy: cpplint: bin/cpplint.py --config=.cpplint --quiet --recursive src plugins examples - -SHELL_FILES := $(shell if [ -d bin ]; then egrep -n -r -l "(env (ba)?sh)|(/bin/(ba)?sh)" bin; fi) - shellcheck: - @if [ -d "bin" ]; then \ - shellcheck ${SHELL_FILES}; \ - fi - + bin/check-shell-scripts.sh SMOKE_SKETCHES := $(sort $(shell if [ -d ./examples ]; then find ./examples -type f -name \*ino | xargs -n 1 dirname; fi)) diff --git a/bin/check-shell-scripts.sh b/bin/check-shell-scripts.sh new file mode 100755 index 00000000..e61339ca --- /dev/null +++ b/bin/check-shell-scripts.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +: "${KALEIDOSCOPE_DIR:=$(pwd)}" +cd "${KALEIDOSCOPE_DIR}" || exit 1 + +ERROR_COUNT=0 + +while read -r SCRIPT; do + shellcheck "${SCRIPT}" + (( ERROR_COUNT += $? )) +done < <(grep -E -n -r -l '(env (ba)?sh)|(/bin/(ba)?sh)' "${KALEIDOSCOPE_DIR}/bin") + +exit $ERROR_COUNT