From 672bb9a728ccca3d295afed26e2751b3823844e3 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Mon, 12 Aug 2024 19:26:05 +0200 Subject: [PATCH] shellcheck: work around old versions of shellcheck ... that do not support `--format=json1`. Related: https://issues.redhat.com/browse/OSH-655 --- scripts/run-shellcheck.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/run-shellcheck.sh b/scripts/run-shellcheck.sh index 1e7dfd1..b458e46 100755 --- a/scripts/run-shellcheck.sh +++ b/scripts/run-shellcheck.sh @@ -44,8 +44,16 @@ filter_shell_scripts"' "$@"' # function that creates a separate JSON file if shellcheck detects anything wrap_shellcheck() { dst="${SC_RESULTS_DIR}/sc-$$.json" - (set -x && timeout "${SC_TIMEOUT}" shellcheck --format=json1 "$@" > "$dst") + + # This is a compatibility workaround for old versions of shellcheck + # that do not support `--format=json1`. + echo '{"comments":' > "$dst" + + (set -x && timeout "${SC_TIMEOUT}" shellcheck --format=json "$@" >> "$dst") EC=$? + + echo '}' >> "$dst" + case $EC in 0) # no findings detected -> remove the output file