Repository navigation
fix: send both streams through a group redirect and capture $(eval …) - #206
Merged
ferdingler merged 4 commits intoNov 9, 2026
Merged
ferdingler merged 4 commits into
ferdingler merged 4 commits into
Conversation
…val …)
A redirect on { …; } kept only a file target for stdout. 2>&1, 2>file and
>&2 dropped the group's output, and a group's stderr was lost on the
terminal. Each of fd 1 and fd 2 now ends at one target, decided by the
redirects in order, as bash does.
Command substitution ran a pipeline without the special-builtin dispatch,
so $(eval …), $(. file) and $(command …) expanded to nothing. A captured
pipeline now takes the same dispatch as a direct one.
ferdingler
marked this pull request as ready for review
November 5, 2026 05:32
This was referenced Nov 5, 2026
ferdingler
enabled auto-merge (squash)
November 8, 2026 21:16
ferdingler
disabled auto-merge
November 9, 2026 22:43
10 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
A redirect on a
{ …; }group only ever handled stdout going to a file. Anything else lost output:{ echo hi; } 2>&1printed nothing,{ echo hi; } 2>/dev/nullswallowed thehitoo,x=$({ cd /nope; } 2>&1)came back empty, and{ ls /nope; } > fdropped the error on the terminal. Separately,$(eval …),$(. file)and$(command …)expanded to nothing, because command substitution skipped the path that runs those builtins. Claude Code's per-command wrapper leans on both of these.Now a group's stdout and stderr each end up where the redirects say, applied in order like bash, so
2>&1 >fsends stderr to the terminal and stdout to the file. Command substitution runs a pipeline the same way a direct command does, so those builtins produce output, andexitinside$(eval …)stops the substitution. Same limit as before for groups: the output is collected and written when the group finishes, so stdout and stderr don't interleave.Evidence of how this is fixed in Box
Strands Box carries a vendored copy of Shell that already does both: it routes a group's two streams by its redirects and runs a captured pipeline through the builtin dispatch (UPSTREAM.md note). I left out its extra buffer that also diverts the shell's own diagnostics during a redirected group: I couldn't find a case here where it changes anything, so I can add it later if it turns out to matter.
Related Issues
None.
Documentation PR
None.
Type of Change
Bug fix
Testing
I checked each case against bash on Linux and added tests for them, including one through the CLI, since the terminal path behaves differently from the captured one. On main, all but one of the new tests fail; the remaining one passes on main through the library and only fails on the terminal, which the CLI test covers. The full Rust suite passes, and fmt and clippy are clean with no new warnings. I didn't run the Python or Node suites locally since neither binding changed. This doesn't depend on #199, but both touch stderr handling in the executor, so whichever lands second may need a small rebase.
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.