Repository navigation
fix(interpreter): exec inside a subshell redirects the subshell - #2615
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 1a88f9c | Commit Preview URL Branch Preview URL |
Oct 08 2026, 03:22 AM |
chaliy
force-pushed
the
claude/subshell-exec-redirect
branch
from
October 8, 2026 01:50
e94a5fe to
fb225e9
Compare
`( exec > log.txt; echo inside )` wrote to the caller's stdout and left log.txt empty. Only the outermost command loop routed the exec fd table, and the subshell's table was restored before control reached it, so the redirect applied to nothing. Routing now happens at the subshell boundary; output written before the `exec` still goes to the caller. Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
chaliy
force-pushed
the
claude/subshell-exec-redirect
branch
from
October 8, 2026 03:21
fb225e9 to
1a88f9c
Compare
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
Stacked on #2610 — review that one first; this PR's own commit is the second one.
What changed
An
execredirect set inside a subshell now applies to the subshell's output.Output the subshell wrote before the
execstill goes to the caller, as inbash, and a write to a descriptor the subshell closed names the command that
tried.
Why
The redirect applied to nothing at all. Only the outermost command loop routed
the exec fd table, and a subshell saves and restores its own table, so by the
time control was back at that loop the subshell's redirect was already gone.
sep,insideinside,sep— and log.txt emptysep,inside( exec 2>err.txt; ls /nope )lost the capture the same way: the error went tothe caller's stderr and err.txt stayed empty.
Before / After
pre,sep,postpre,post,sep— log.txt emptypre,sep,postbash and bashkit now both say
bash: line 1: echo: write error: Bad file descriptorand exit 1.Risk
Low, and contained to the subshell boundary. The routing helper gained a
"keep" floor so the split between what the caller sees and what the redirect
takes does not depend on whether a streaming callback is attached — the
in-process
exec()path and the CLI now agree. Two interpreter fields trackwhere the enclosing sequence stood when
execinstalled its target, and thename of the last simple command, for a diagnostic raised after that command
returned.
An
execredirect inside abash -cchild still does not take effect;L-PROC-001 is updated to say so.
Checklist
cargo test -p bashkit --lib(2920 passed)cargo test -p bashkit --test integration(1376 passed)bash_comparisondifferential tests against real bashcargo clippy -p bashkit --all-targets -- -D warningscargo fmt --all --checkcargo test -p bashkit-cli(56 passed)just check-okflog.md,limitations.mdL-PROC-001)https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
Generated by Claude Code