Skip to content

fix(scripts): check-shell-lint: here-string, not printf | grep -q under pipefail - #1304

Merged
bpalermo merged 2 commits into
mainfrom
fix/shell-lint-sigpipe
Oct 6, 2026
Merged

bpalermo merged 2 commits into
mainfrom
fix/shell-lint-sigpipe

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

What

scripts/check-shell-lint.sh looked a file up in the covered set with printf '%s\n' "$covered" | grep -qxF "$f" under set -euo pipefail. grep -q exits on its first match. If printf still has output to write, it gets SIGPIPE (or EPIPE, printf: write error: Broken pipe), the pipeline returns non-zero, and a covered file is reported as uncovered. This is what made #1290's first CI run fail on e2e/agent-restart-gap.sh.

The lookup is now grep -qxF -- "$f" <<<"$covered", which has no pipe.

Test

New target //scripts:check_shell_lint_test. It is hermetic: fake bazel query and fake git ls-files, no repository and no Bazel.

  • All covered: exit 0. One file outside every target: exit 1, and only that file is named. Empty query: exit 1 (the No shell script in the root workspace is linted: the shellcheck aspect has no sh_* target to visit #853 state).
  • The fake covered set is about 1.6 MiB, with the real labels sorting first. That is far past the 64 KiB pipe buffer, so the old shape fails every time rather than by chance.
  • An anti-vacuity case puts the old printf | grep -q lookup back into a copy, checks that the rewrite actually happened, and asserts the copy reports a covered file as uncovered.
  • Run against the unfixed origin/main script, the test fails. All four covered files come back "uncovered".

Checks run: bazel test //scripts:check_shell_lint_test --runs_per_test=20 (20/20 pass), make check-shell-lint (OK, 77 scripts), make format-check, bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //....

Same shape elsewhere (reported, not changed here)

Searched scripts/*.sh for producer | grep -q under pipefail:

  • scripts/check-registry-config.sh:115 runs tr -d … <MODULE.bazel | grep -qF …. It is safe today because the files are 18.6 KB and 16.1 KB, under the 64 KiB pipe buffer. Once a MODULE.bazel grows past that, an early match turns into a false "does not override".
  • scripts/check-registry-config.sh:157/164/222/229, scripts/check-registry-lookup.sh:346, scripts/quay-smoke.sh:357 and the fake in scripts/check-publish-verify-control.sh:100 all pipe one short string, written in a single write(), so they are not at risk.
  • head -1 … | grep -Eq in check-shell-lint.sh:56 and lint-proxy.sh:37: head writes one line, so this is not at risk.
  • Outside scripts/: .github/workflows/main.yaml:289 runs gh … --jq '.comments[].body' | grep -qF "$marker". It is not at risk today. The step sets no shell:, so Actions runs it under bash -e {0} without pipefail, and the status is grep's. If someone later adds shell: bash (which means -eo pipefail) or set -o pipefail, it becomes this same trap.

Closes #1297

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…er pipefail

The covered-set lookup was `printf '%s\n' "$covered" | grep -qxF "$f"` under
`set -euo pipefail`. grep -q exits at its first match; when printf still has
output left it dies of SIGPIPE, the pipeline returns 141, and a covered file
is reported as uncovered (#1290's first CI run, e2e/agent-restart-gap.sh).
Use `grep -qxF -- "$f" <<<"$covered"`.

//scripts:check_shell_lint_test runs the check against a fake `bazel query`
and fake `git ls-files`. The fake covered set is ~1 MiB with the real labels
sorting first, so the old shape fails every time, not by luck; an
anti-vacuity case rebuilds the old lookup and asserts it does fail there.

Closes #1297

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 76d53f9 into main Oct 6, 2026
25 checks passed
@bpalermo
bpalermo deleted the fix/shell-lint-sigpipe branch October 6, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scripts/check-shell-lint.sh: printf | grep -q under pipefail → SIGPIPE false 'uncovered' (CI flake)

1 participant