Repository navigation
fix: join continued source lines without empty words - #243
Merged
pgrayy merged 2 commits intoNov 11, 2026
Merged
Conversation
zastrowm
previously approved these changes
Nov 11, 2026
zastrowm
approved these changes
Nov 11, 2026
3 tasks done
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.
Description
Backslash-newline continuations can execute a command before its next physical line is read. Removing a continuation can also introduce an empty argument or reject valid grouped commands.
For example, this is one command written across two physical lines:
Before the fix, the shell prints
<first>and<>, then tries to runsecondas a separate command and exits with status 127. After the fix, it prints:The command exits with status 0 and no error.
The source executor tells the shared parser whether more physical lines remain. The lexer uses that context to defer a trailing escape and omits words emptied by continuation removal. The lexer retains explicitly quoted empty words as tokens and preserves the existing end-of-input escape handling. Alias expansion uses a bounded cursor adjustment when replacements remove tokens.
Some quoted empty arguments are still lost during execution. Continuations inside operators or variable names remain outside this fix.
Related Issues
Companion to strands-agents/box#402, which applies the same fix to Box's vendored Shell. This PR uses upstream's existing string errors and the same three regression tests.
Documentation PR
No separate documentation PR is needed for this bug fix. Parser doc comments explain the new input flag, and the example above shows the behavior change.
Type of Change
Bug fix
Testing
Validated on macOS against
def7ab7:shscripts, argument boundaries, quoting, heredocs, aliases, and a continuation at end of input. The empty-alias case fails if the cursor fix is removed.cargo test --locked --workspace --all-targets: 2,130 passed, no failures or ignored tests.cargo test --locked --workspace --doc: 16 passed; one existing macro example is ignored.cargo test --locked --lib --features node: 64 passed.cargo fmt --all -- --checkandcargo clippy --locked --workspace --all-targets: passed; warning diagnostics match the pre-fix baseline.RUSTDOCFLAGS='-D warnings' cargo doc --locked --workspace --no-depsandcargo build --locked --no-default-features: passed.Python and JavaScript binding suites, WASM, Linux, and Windows were not run locally. No binding code changed.
cargo test --workspace --all-targets,pytest tests/python,npm test)cargo fmtandcargo clippyChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.