Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/differential-shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
name: Differential ShellCheck
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

Expand Down
13 changes: 10 additions & 3 deletions scripts/run-shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,31 @@ filter_shell_scripts"' "$@"'
# function that creates a separate JSON file if shellcheck detects anything
wrap_shellcheck() {
dst="${SC_RESULTS_DIR}/sc-$$.json"
log="${dst%.json}.log"

# compatibility workaround for old versions of shellcheck
echo -n "$SC_RESULTS_BEG" > "$dst"

(set -x && timeout "${SC_TIMEOUT}" shellcheck "${SC_OPTS[@]}" "$@" >> "$dst")
(set -x && timeout "${SC_TIMEOUT}" shellcheck "${SC_OPTS[@]}" "$@" >> "$dst" 2> "$log")
EC=$?

# compatibility workaround for old versions of shellcheck
echo -n "$SC_RESULTS_END" >> "$dst"

case $EC in
0)
# no findings detected -> remove the output file
rm -f "$dst"
# no findings detected -> remove the output files
rm -f "$dst" "$log"
;;

1)
# findings detected -> successful run
if [ -n "$(<"$log")" ]; then
# something printed to stderr -> record an internal error of shellcheck
sed -re 's|^(shellcheck): ([^:]+): (.*)$|\2: internal error: \3 <--[\1]|' "$log" > "$dst"
else
rm -f "$log"
fi
return 0
;;

Expand Down