tools/shellcheck.sh: allow overriding the shellcheck path
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 29 Jan 2024 21:54:10 +0000 (16:54 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 7 Feb 2024 21:12:33 +0000 (16:12 -0500)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11755
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
tools/shellcheck.sh

index 6cf23b3b1e7f485da8483eaf91e1e43051ca6f26..100e2582275f66536a6f797f07a0c820730775c2 100755 (executable)
@@ -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/*' \
This page took 0.025529 seconds and 4 git commands to generate.