fix(qa): unwrap-budget.sh silently passes on Windows checkouts with CRLF .unwrap-budget - #3009
Conversation
…indows scripts/qa/unwrap-budget.sh stripped spaces and LF from .unwrap-budget via `tr -d ' \n'` but not CR. On any checkout with core.autocrlf=true (the Git-for-Windows installer's recommended default), .unwrap-budget gets CRLF line endings, so BUDGET becomes "163\r". The subsequent `[[ "$CURRENT" -gt "$BUDGET" ]]` / `-lt` comparisons then throw a bash arithmetic syntax error that -- being inside an if condition, exempt from set -e -- is silently swallowed, and the script exits 0 regardless of whether the budget is actually exceeded. Verified with a genuinely-exceeded CRLF budget (count=158, budget=1): the unpatched script still exits 0. Strip \r too so the comparison sees a clean integer on any platform.
|
😎 Merged successfully - details. |
No issues found. Generated by Claude Code |
|
@GuTS805 the Trunk merge queue failed for this PR. See the Trunk merge-status comment for details. Posted as a new comment so GitHub sends an email — Trunk's sticky comment is edited in place and won't trigger a notification. |
Problem
scripts/qa/unwrap-budget.sh— part of the mandatorymake qa-fastpre-commit gate documented in CLAUDE.md/AGENTS.md — strips spaces/LF from.unwrap-budgetbut not CR:On any checkout with
core.autocrlf=true(the Git-for-Windows installer's recommended default),.unwrap-budgetgets CRLF line endings, soBUDGETbecomes"163\r". The subsequentthen throw a bash arithmetic syntax error that — being inside an
ifcondition, exempt fromset -e— is silently swallowed, and the script exits 0 regardless of whether the budget is actually exceeded.Verified this is a genuine silent gate bypass, not just noisy output: with a CRLF-terminated budget file set to
1and the real unwrap/expect count at 158 (158 >> 1), the unpatched script still exits 0.Fix
Strip
\rtoo:Validation
bash scripts/qa/unwrap-budget.shnow passes cleanly on a CRLF-terminated.unwrap-budget(verified on a fresh checkout withcore.autocrlf=true).unwrap-budgettypos.sh,audit.sh,semver.sh) for the same class of bug — none read a checked-in single-value file the same way, so this appears isolated tounwrap-budget.shClass A (mechanical one-line shell fix, no behavior change beyond correcting the bug) —
make qa-fastis sufficient.Not a duplicate of prior
unwrap-budget.shfixes (#2002 / #2012 / #2261 — those addressed awk truncation and test-code miscounting, not line endings).Fixes #3008