From: Michael Jeanson Date: Tue, 7 Nov 2023 19:21:27 +0000 (-0500) Subject: tools: Add shellcheck.sh X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=86a9f7d3ddc61ee4eded90bfa4c15bf828c1209d tools: Add shellcheck.sh This script will run ShellCheck on all files in the tree with the '.sh' extension and return a non-zero exit code if any of the files has an issue. Change-Id: Ib65dcf1c9bd447a92a773284cc138ec0ed01444b Signed-off-by: Michael Jeanson Signed-off-by: Philippe Proulx Reviewed-on: https://review.lttng.org/c/babeltrace/+/11293 --- diff --git a/Makefile.am b/Makefile.am index adb11cd8..0f4493b5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,4 +33,5 @@ EXTRA_DIST = \ std-ext-lib.txt \ tools/format-cpp.sh \ tools/lint-py.sh \ + tools/shellcheck.sh \ version diff --git a/tools/shellcheck.sh b/tools/shellcheck.sh new file mode 100755 index 00000000..6cf23b3b --- /dev/null +++ b/tools/shellcheck.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# SPDX-License-Identifier: GPL-2.0-only +# +# SPDX-FileCopyrightText: 2023 Michael Jeanson + +set -eu + +retcode=0 + +while read -r script_file; do + echo "Running ShellCheck on \`$script_file\`" + pushd "${script_file%/*}" >/dev/null + shellcheck -x "${script_file##*/}" || retcode=$? + popd >/dev/null +done <<< "$(find . -type f -name '*.sh' \ + ! -path './.git/*' \ + ! -path ./config/ltmain.sh \ + ! -path ./tests/utils/tap-driver.sh \ + ! -path ./tests/utils/tap/tap.sh)" + +exit $retcode