Repository navigation
fix(parser): run commands before a later syntax error; quote/heredoc-aware $( ) end - #2513
Merged
Merged
Conversation
…aware $( ) end Bash reads and runs a script line by line, so commands before a syntax error execute and the error is reported afterwards (exit 2). Bashkit rejected the whole script, losing all earlier work. Also find the end of $(...) with a shared scanner aware of quotes, escapes, backticks, comments and heredoc bodies; $(cat <<'E' ... ) ... E) and $(echo ")") were cut at the inner paren. Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 7eb4558 | Commit Preview URL Branch Preview URL |
Oct 06 2026, 07:42 PM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Михайло · project thread
What changed
exit/set -ebefore the error still win, the EXIT trap runs, andbash -nkeeps whole-script rejection. With nothing runnable before the error,exec()still returnsErr(Parse)as before. Applies to top-levelexecand childbash/sh.$(...)is found correctly. One shared scanner (parser/subst_scan.rs) for the lexer andparse_wordnow skips parens inside quotes, escapes, backticks, comments and heredoc bodies.<<<and arithmetic<<are not treated as heredocs.Step 1 of the "closer to real bash" roadmap.
Why
Agents send long multi-line scripts. One typo near the end threw away every earlier command, unlike bash. And common shapes were rejected outright, e.g. a
git commit -m "$(cat <<'EOF' ... (scope) ... EOF)"message containing a), or$(echo ")").Before / After
The new spec cases pass
bash_comparison_testsagainst real bash locally.Risk
knowledge/foundations/parser.md: a barecasepattern)inside$(...)still closes early, the same as before.Checklist
https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
Generated by Claude Code