mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
The file list came from `find .`, so every path carried a leading './'. shellcheck writes those paths verbatim into its `-f diff` output, and `git apply` rejects a diff whose paths start with './' as "invalid path", which aborts the whole autoformat run. The autofix branch was therefore dead from the start and nobody noticed: it only runs when shellcheck actually has something to correct, and until now it never did. The first real finding turned a silent no-op into a red `make quality`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
33 lines
723 B
Bash
Executable File
33 lines
723 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# shellcheck shell=bash
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/../.." && pwd)"
|
|
|
|
cd "${REPO_ROOT}"
|
|
|
|
mapfile -t shellcheck_files < <(find . -type f -name '*.sh' 2>/dev/null | sed 's|^\./||' | sort)
|
|
if [[ "${#shellcheck_files[@]}" -eq 0 ]]; then
|
|
printf 'No shell scripts found.\n'
|
|
exit 0
|
|
fi
|
|
|
|
diff_file="$(mktemp)"
|
|
cleanup() {
|
|
rm -f "${diff_file}"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
set +e
|
|
shellcheck -f diff -x "${shellcheck_files[@]}" >"${diff_file}" 2>/dev/null
|
|
set -e
|
|
|
|
if [[ -s "${diff_file}" ]]; then
|
|
printf 'Applying ShellCheck autofixes.\n'
|
|
git apply --whitespace=nowarn "${diff_file}"
|
|
fi
|
|
|
|
shellcheck -x "${shellcheck_files[@]}"
|