Skip to content

Commit b1781ef

Browse files
committed
workflows: scan all shell scripts
Instead of just scripts/*.sh, scan all scripts found in the repository using `file`. I didn't find a widely accepted mechanism to do this so settled on using `file`. The script is at least not too long to follow, doesn't introduce any external dependency, and is careful to avoid errors from unusual characters in filenames (eg. backslash escapes and carriage returns) to try and be safe against all inputs. If this pattern works, we could extend it to the other lint checks in this file. Signed-off-by: Robie Basak <[email protected]>
1 parent ca08110 commit b1781ef

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

.github/workflows/static-checks.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ jobs:
5151
runs-on: ubuntu-latest
5252
steps:
5353
- name: Install ShellCheck
54-
run: sudo apt update && sudo apt -y install shellcheck
54+
run: sudo apt update && sudo apt -y install shellcheck file
5555

5656
- uses: actions/checkout@v4
5757
with:
5858
fetch-depth: 0
5959

6060
- name: Run ShellCheck
61-
run: shellcheck scripts/*.sh
62-
61+
run: |
62+
# Run shellcheck against all files outside .git/ that `file` reports
63+
# as text/x-shellscript
64+
find . -path ./.git -prune -o -print0 | \
65+
xargs -0n1 sh -c 'test "$(file --brief --mime-type "$1")" = "text/x-shellscript" && printf "%s\000" "$1"' -- | \
66+
xargs -0t shellcheck

0 commit comments

Comments
 (0)