Skip to content
Merged
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
19 changes: 15 additions & 4 deletions sh/shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@ set -euo pipefail

cd "$(git rev-parse --show-toplevel)"

scripts=()
# Ask shfmt about tracked files only: walking the tree races any tool creating and removing
# untracked directories, such as a concurrent `bun install` under node_modules.
tracked=()
while IFS= read -r -d '' file; do
if git --literal-pathspecs ls-files --error-unmatch -- "$file" >/dev/null 2>&1; then
scripts+=("$file")
# Skip a tracked file deleted from the worktree.
if [[ -f $file ]]; then
tracked+=("$file")
fi
done < <(shfmt -f=0 .)
done < <(git ls-files -z)
((${#tracked[@]})) || exit 0

scripts=()
while IFS= read -r -d '' file; do
scripts+=("$file")
done < <(shfmt -f=0 -- "${tracked[@]}")
# A failed listing would lint a partial set and pass or fail on the wrong files.
wait "$!"
((${#scripts[@]})) || exit 0

case "${1:-}" in
Expand Down