Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(qa): unwrap-budget.sh silently passes on Windows checkouts with CRLF .unwrap-budget - #3009

Merged
trunk-io[bot] merged 1 commit into
dora-rs:mainfrom
GuTS805:fix/unwrap-budget-crlf
Aug 4, 2026
Merged

fix(qa): unwrap-budget.sh silently passes on Windows checkouts with CRLF .unwrap-budget#3009
trunk-io[bot] merged 1 commit into
dora-rs:mainfrom
GuTS805:fix/unwrap-budget-crlf

Conversation

@GuTS805

@GuTS805 GuTS805 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Problem

scripts/qa/unwrap-budget.sh — part of the mandatory make qa-fast pre-commit gate documented in CLAUDE.md/AGENTS.md — strips spaces/LF from .unwrap-budget but not CR:

BUDGET=$(cat "$BUDGET_FILE" | tr -d ' \n')

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

if [[ "$CURRENT" -gt "$BUDGET" ]]; then ...
if [[ "$CURRENT" -lt "$BUDGET" ]]; then ...

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 this is a genuine silent gate bypass, not just noisy output: with a CRLF-terminated budget file set to 1 and the real unwrap/expect count at 158 (158 >> 1), the unpatched script still exits 0.

Fix

Strip \r too:

-BUDGET=$(cat "$BUDGET_FILE" | tr -d ' \n')
+BUDGET=$(cat "$BUDGET_FILE" | tr -d ' \r\n')

Validation

  • bash scripts/qa/unwrap-budget.sh now passes cleanly on a CRLF-terminated .unwrap-budget (verified on a fresh checkout with core.autocrlf=true)
  • Confirmed the fix still correctly fails (exit 1, clear message) when the budget is genuinely exceeded, even with a CRLF-terminated .unwrap-budget
  • Checked sibling QA scripts (typos.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 to unwrap-budget.sh

Class A (mechanical one-line shell fix, no behavior change beyond correcting the bug) — make qa-fast is sufficient.

Not a duplicate of prior unwrap-budget.sh fixes (#2002 / #2012 / #2261 — those addressed awk truncation and test-code miscounting, not line endings).

Fixes #3008

…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.
@trunk-io

trunk-io Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

😎 Merged successfully - details.

phil-opp commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

🤖 Automated review by Claude — fully automated, no human in the loop.

No issues found. tr -d ' \r\n' correctly extends the strip set to include CR: tr interprets the \r/\n escapes in the single-quoted set, so a CRLF .unwrap-budget now yields a clean integer instead of 163\r, which was tripping the swallowed bash arithmetic error and letting the check exit 0 regardless. Escape handling for \r is portable across GNU/BSD/macOS tr. The fix is complete and the commit message's reproduction matches the observed behavior.


Generated by Claude Code

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@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.

@trunk-io
trunk-io Bot merged commit c5770a9 into dora-rs:main Aug 4, 2026
16 checks passed
@GuTS805
GuTS805 deleted the fix/unwrap-budget-crlf branch August 4, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scripts/qa/unwrap-budget.sh silently passes (exit 0) regardless of budget on any Windows checkout with core.autocrlf=true

2 participants