diff --git a/sh/shell.sh b/sh/shell.sh index fb6ae022c8..72f9f251fb 100755 --- a/sh/shell.sh +++ b/sh/shell.sh @@ -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