Skip to content

fix(interpreter): match bash stderr for set -x, syntax errors and TIMEFORMAT - #2635

Merged
chaliy merged 3 commits into
mainfrom
claude/stderr-text-parity
Oct 8, 2026
Merged

chaliy merged 3 commits into
mainfrom
claude/stderr-text-parity

Conversation

@chaliy

@chaliy chaliy commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

  • set -x quotes traced words like bash, traces assignments, function calls, eval/source and [[ ]] terms, expands PS4 and repeats its first char per $(...)/eval/source/trap level. Trace lines are ordered with pending $(...) stderr.
  • Parse errors use bash wording: "syntax error near unexpected token T'" plus the source line, "unexpected end of file", "unexpected EOF while looking for matching". Reports are named bash: -c, the script path, $0: evalor the sourced file via newError::syntax_report`.
  • time honors TIMEFORMAT (%[p][l]R, %%; CPU fields print unavailable).
  • [[ ! a || b ]] negates only a; $LINENO in [[ ]]/(( )) keeps the enclosing line; bash/sh children apply their redirects to their own errors.

Why

Level-up roadmap, fidelity step: stderr text was the main remaining gap in the bash oracle.

Before / After (verified)

bash-oracle strict: 94 → 99 / 106 (match stays 101). floor.txt raised to 101 99.

Script set -x; x="a b"; echo "$x" 'it''s'; y=$(echo hi) plus bash -c 'if then fi', stderr from bash 5.2 and this branch is identical:

+ x='a b'
+ echo 'a b' its
++ echo hi
+ y=hi
bash: -c: line 1: syntax error near unexpected token `then'
bash: -c: line 1: `if then fi'

Before, traces were unquoted with no assignment lines, and parse errors used bashkit's own parser wording.

Risk

  • Error::syntax_report is new public API.
  • Remaining gaps documented in knowledge/operations/limitations.md (no trace of for/case/select headers, <(...), some parse errors keep bashkit wording).
  • Stack use checked against main for the coverage job (branch 1,893,376 vs main 1,909,696 bytes).

Checklist

  • Failing tests first (xtrace.test.sh, parse-errors.test.sh, time.test.sh), verified against bash 5.2
  • fmt, clippy, integration, lib, CLI, bash_comparison
  • knowledge updated (log, limitations, parser)

Generated by Claude Code

…EFORMAT

set -x quotes traced words like bash, traces assignments, function calls,
eval/source and [[ ]] primaries, expands PS4 and repeats its first
character per $(...)/eval/source/trap level. Trace lines queue with the
pending $(...) stderr so they follow the substitutions that built them
and precede the command's redirects; function/eval trace lines now reach
the streaming callback.

Grammar errors are worded by the token the parser stopped at ("syntax
error near unexpected token `T'" plus the source line, or "syntax error:
unexpected end of file" on the line after the last), unterminated quotes
and an unclosed [[ =~ ( group read like bash, and reports are named
bash: -c, the script path, $0: eval or the sourced file
(Error::syntax_report). Empty if/while conditions fail at then/do.
bash/sh children apply their redirects to their own errors.

time honors TIMEFORMAT (%[p][l]R, %%; CPU fields stay unavailable).
[[ ! a || b ]] negates only a; $LINENO in [[ ]]/(( )) keeps the
enclosing list's line.

bash-oracle strict 94 -> 99/106.
@chaliy chaliy self-assigned this Oct 8, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit b797d71 Commit Preview URL

Branch Preview URL
Oct 08 2026, 08:18 AM

@chaliy
chaliy merged commit 1f894cd into main Oct 8, 2026
46 checks passed
@chaliy
chaliy deleted the claude/stderr-text-parity branch October 8, 2026 08:43
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.

1 participant