Repository navigation
fix(interpreter): exec >file redirects the shell's own output - #2593
Merged
Merged
Conversation
`exec >log 2>&1` was recorded but only used by `>&N`, so output still
printed. Route fd 1/2 entries per top-level command, pause streaming for
redirected streams, pass `>&3` saved-original writes through, normalize
`exec 1>&3` restores, and keep `$(cmd 2>&1)` capturing. A failed open
leaves the fd alone; an unset `{var}` no longer falls back to fd 1.
Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | b93a3b3 | Commit Preview URL Branch Preview URL |
Oct 07 2026, 08:13 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
exec >log 2>&1,exec >>logandexec 2>/dev/nullnow redirect the script's own output. Before, the fd table recorded them but only>&Nlookups used it, so everything still printed to the caller.route_exec_output). Streaming is paused for the redirected streams.exec 3>&1 >log; echo x >&3still reaches the caller through a passthrough buffer.exec 1>&3 3>&-restores.$( )and pipelines keep their own stdout.$(cmd 2>&1)still captures instead of writing to the log.exec >/bad/pathleaves fd 1 alone and returns status 1.exec {var}>fwithvarunset no longer clobbers fd 1. Allocating an fd intovaris still not implemented and is noted in L-PROC-001.Why
This is a roadmap step 1 fidelity gap from the Debian-oracle case
exec-redirect-whole-script.exec > >(tee log) 2>&1-style logging at the top of a script is a common agent pattern. In bashkit it silently did nothing.Before / After
exec >/tmp/l 2>&1; echo one; ls /nope/tmp/lexec 2>/dev/null; ls /nope; echo rc=$?rc=2onlyexec 3>&1 >/tmp/l; echo a; echo b >&3a,bb(andain the log)exec >/tmp/l; x=$(echo cap); exec >&3; echo $xcapProof: new spec
exec-redirect-shell-output.test.sh(5 cases, bash-verified, run through both the library and the CLI) and new streaming testexec_redirected_output_is_not_streamed.bash_comparisonpasses, and the oracle case now matches.Risk
Medium-low. The change only applies while
exechas redirected fd 1/2. Output written before theexecin the same top-level command, and not streamed yet, also goes to the log (documented in L-PROC-001). The depth-50 nested$( )stack need is unchanged.Checklist
cargo test -p bashkit --lib/--test integration/bash_comparison-D warnings, fmt,check-okfhttps://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
Generated by Claude Code