tools: Add shellcheck.sh
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 7 Nov 2023 19:21:27 +0000 (14:21 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 23 Jan 2024 15:38:15 +0000 (10:38 -0500)
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 <mjeanson@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11293

Makefile.am
tools/shellcheck.sh [new file with mode: 0755]

index adb11cd82682adc0f1058e865ad719a2f32a67b1..0f4493b537c9c6680b7868c172b35e809a3c70d5 100644 (file)
@@ -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 (executable)
index 0000000..6cf23b3
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# SPDX-FileCopyrightText: 2023 Michael Jeanson <mjeanson@efficios.com>
+
+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
This page took 0.026701 seconds and 4 git commands to generate.