Repository navigation
fix(parser): heredoc backslash escapes; read without -r - #2581
Merged
Merged
Conversation
Unquoted heredoc bodies treat \$, \` and \\ as literals, join \<newline> lines and run backtick substitution. `read` without -r removes backslashes, joins continued lines, and returns 1 when input ends before the delimiter. Pipe consumption follows -d/-n. Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 9f3bf78 | Commit Preview URL Branch Preview URL |
Oct 07 2026, 05:57 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
\$,\`and\\are literal,\<newline>joins lines (also inside$((…))), other backslashes stay, and backtick substitution runs.readwithout-rremoves backslashes. An escaped IFS character stays inside its field (read a b <<< 'x\ y z'givesa='x y'), and\<newline>joins the next line.readreturns 1 when input ends before the delimiter but still assigns the data (printf abc | read v). An empty stdin returns 1.readfrom a shared pipe ({ read; read; },while read) now consumes one record that honours-d,-nand continuation. Before, it always took one line.Why
Oracle failures
shell/heredoc-expandandshell/read-optionsfrom the pseudo-linus list.Before / After
literal \$user e \crase``literal \agente e \crase``literal $user e `crase``echo bt``echo bt`btread a <<< 'barra\invertida'barra\invertidabarrainvertidaread nada < /dev/null; echo $?01printf 'a;b' | { read -d ';' p; read -d ';' q; echo $p $q; }a bNew spec
heredoc-read-escapes.test.shhas 5 cases, all verified against bash. Read unit tests that fed unterminated input and expected status 0 now pass newline-terminated input, since bash returns 1 for unterminated input.Risk
Medium.
readstatus at EOF changes for unterminated input, matching bash; thewhile read || [ -n "$l" ]idiom keeps working (covered). All lib, integration and bash_comparison tests pass.Checklist
cargo fmt,cargo clippy -D warningshttps://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
Generated by Claude Code