Skip to content

Commit

Permalink
shellcheck: work around old versions of shellcheck
Browse files Browse the repository at this point in the history
... that do not support `--format=json1`.

Related: https://issues.redhat.com/browse/OSH-655
  • Loading branch information
kdudka committed Aug 12, 2024
1 parent a1e9e70 commit 402510b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/run-shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 402510b

Please sign in to comment.