Skip to content

fix(interpreter): eval syntax errors exit 2 with bash's line prefix - #2596

Merged
chaliy merged 1 commit into
mainfrom
claude/eval-syntax-status
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/eval-syntax-status

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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

What changed

  • eval with a syntax error exits with status 2 (was 1), like bash.
  • The message is bash: eval: line N: syntax error: ... followed by bash: eval: line N: \', both newline-terminated. N counts from the line of the eval` itself.
  • The eval's own redirects apply to the error, so x=$(eval "$bad" 2>&1) captures it (it was dropped before).
  • $LINENO inside $( ) counts from the outer script line instead of restarting at 1.

Why

Debian-oracle gaps: scripts that probe syntax with eval and check $? -eq 2, and scripts that log $LINENO from command substitutions.

Before / After

Script Before After (matches bash)
eval "if then"; echo $? 1 2
x=$(eval fi 2>&1); echo "$x" empty bash: eval: line 1: syntax error: ...
error text end no trailing newline (...clauserc=1) newline-terminated
line 3: x=$(echo $LINENO) 1 3

New spec file eval-syntax-error.test.sh (4 cases), verified against bash 5.2. The parser's message wording still differs from bash's near unexpected token text; tests check the prefix and status only.

Risk

Low. The parser change only shifts line numbers of $( ) bodies. The two-MiB recursion stack probe (f() { f; }; f under ulimit -s) needs 2028 KB on this branch and 2032 KB on main.

Checklist

  • Failing spec first, verified against real bash
  • cargo test -p bashkit --lib, --test integration, bash_comparison
  • cargo clippy --all-targets -D warnings, cargo fmt --check
  • knowledge/log.md updated

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

@chaliy chaliy self-assigned this Oct 7, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 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 1fa7d56 Commit Preview URL

Branch Preview URL
Oct 07 2026, 09:42 PM

@chaliy
chaliy force-pushed the claude/eval-syntax-status branch from 8920905 to 4f95d26 Compare October 7, 2026 21:12
eval parse failures now return status 2, print "bash: eval: line N:" with
the offending source line, and honor the eval's redirects. Command
substitution bodies are parsed from the outer line so $LINENO matches.

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy
chaliy force-pushed the claude/eval-syntax-status branch from 4f95d26 to 1fa7d56 Compare October 7, 2026 21:42
@chaliy
chaliy merged commit 77f58e0 into main Oct 7, 2026
44 checks passed
@chaliy
chaliy deleted the claude/eval-syntax-status branch October 7, 2026 22:00
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