From 402510b77e84319df7173c01a09798c618f9b553 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 f3025d9..97be4ad 100755 --- a/scripts/run-shellcheck.sh +++ b/scripts/run-shellcheck.sh @@ -43,8 +43,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