From: Simon Marchi Date: Mon, 29 Jan 2024 21:54:10 +0000 (-0500) Subject: tools/shellcheck.sh: allow overriding the shellcheck path X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=b939afe57d2f5911460fab65e334b789d2a96bd5 tools/shellcheck.sh: allow overriding the shellcheck path For an unknown (to me) reason, the shellcheck binary from the Arch Linux package (version 0.9.0-79) hits this error: $ tools/shellcheck.sh ... Running ShellCheck on `./tests/cli/test-intersection.sh` shellcheck: (Array.!): undefined array element ... This looks like an error internal to shellcheck. When using the Linux x86-64 binary from the release [1], it works fine. Add a way to override the shellcheck binary in shellcheck.sh, to make working around this easier: $ SHELLCHECK=/home/smarchi/Downloads/shellcheck-v0.9.0/shellcheck tools/shellcheck.sh ... all fine ! [1] https://github.com/koalaman/shellcheck/releases/tag/v0.9.0 Change-Id: I81f0ea2e40b9dbac75e0b0debcce63338986358c Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/11755 Tested-by: jenkins Reviewed-by: Philippe Proulx --- diff --git a/tools/shellcheck.sh b/tools/shellcheck.sh index 6cf23b3b..100e2582 100755 --- a/tools/shellcheck.sh +++ b/tools/shellcheck.sh @@ -6,12 +6,13 @@ set -eu +shellcheck=${SHELLCHECK:-shellcheck} retcode=0 while read -r script_file; do echo "Running ShellCheck on \`$script_file\`" pushd "${script_file%/*}" >/dev/null - shellcheck -x "${script_file##*/}" || retcode=$? + "$shellcheck" -x "${script_file##*/}" || retcode=$? popd >/dev/null done <<< "$(find . -type f -name '*.sh' \ ! -path './.git/*' \