Repository navigation
WIP: list-level input procsub materialization (rubash#2235) - #2253
Merged
Merged
Conversation
…2235)
GNU walks ONE ordered redirect list in the child (redir.c:237
do_redirections; each entry's word expanded at its own turn,
redirection_expand redir.c:298) and a <(...) word forks its
producer at expansion (subst.c:6362 process_substitute). A numbered
entry `3< <(...)` therefore binds fd 3 for every command class, and
a later `<&3` in the same list dups that binding.
Master served only the fd-0 redirect_in mirror and the {var}
applier, so on a simple external command the producer was never
spawned; the spawn loop also skipped alias-spelled targets, and the
fd-0 stdin dup resolved <&N only against the ambient fd table —
`cat 3<seed <&3` failed even for plain files.
- command_with_process_substitution_files gains the input list
pass (the input-side sibling of #2196's output pass): every
unserved Input/ReadWrite list position materializes like the
redirect_in arm — stream-first to a /dev/fd/N word registered in
the fd table, timed collection as the spawn-failure fallback.
The field arm records its served position in both branches so
its entry is never materialized twice, and procsub_spawn_plan
binds a later consumer's prefix fd to the streamed endpoint.
- apply_external_stdin_redirect, on an ambient miss, replays the
command's own list before the dup (own_numbered_input_binding):
the last earlier binding of N wins and is opened once; the
description is stashed in own_input_bindings and
spawn_external_process stamps/pins that same description at N
(GNU's dup2 shape) instead of opening the target twice. The
spawn loop also gains the alias arm: a numbered Input/ReadWrite
entry targeting /dev/fd/M binds M's File endpoint through the
#1686 env/pin channels.
- The materialized alias spelling must be consumable by every
numbered-input resolver, so the in-process binders gain the same
alias rule (an alias target resolves through the fd table, the
rubash#1963 layer — never a filesystem open of the spelling,
whose real fd is an unrelated descriptor):
open_compound_numbered_input_redirects (compounds, function
calls, loops), read_redirected_fd (read -u N), and
mapfile_redirected_fd_input (mapfile -u N).
Pins: tests/issue2235_list_input_procsub_regressions.rs — 8 numbered
cells red on master (external dup of own procsub input, sort shape,
sh child, rubash child, plain-file sibling, 0<&3, last-wins with
both producers running, producer side effect without a consumer)
plus 3 controls green on master (exec / group / {var}). Probe
batteries (33 cells, script files) are byte-identical to GNU Bash
5.3.20 except the pipeline-stage cells, whose stage runners do not
run the ordered own-list application at all — recorded as a
residual in the cluster report.
Refs #2235
# Conflicts: # src/executor/command_substitution.rs # src/executor/init.rs # src/executor/mod.rs
caomengxuan666
added a commit
that referenced
this pull request
Oct 30, 2026
Resolve external_inner.rs against #2253/#2263: keep the #2235 stash lookup ahead of the #2270 heredoc arm (a heredoc entry still classifies as write at lookup time, so it can never claim a stash — matching the dup replay, which kind-skips heredocs; a same-fd stash belongs to an earlier plain entry and the heredoc's later stamp preserves last-wins). Semantic check: diff vs master is exactly this PR's change set. Refs #2270
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.
Refs #2235
What
List-level INPUT process substitution on simple external commands (
cat 3< <(...) <&3and family) was never materialized: the materializer served only the fd-0redirect_inmirror and the{var}applier, the spawn loop skipped alias-spelled targets, and the fd-0 stdin dup resolved<&Nonly against the ambient fd table (so the plain-file siblingcat 3<seed <&3failed too).GNU ground truth:
do_redirections(redir.c:237) walks one ordered list;redirection_expand(redir.c:298) expands each entry at its turn;process_substitute(subst.c:6362) forks the producer at expansion.Changes
command_with_process_substitution_files(input-side sibling of [bug] 带号 fd 的 output procsub 消费者输出全路径缺失:cat 3> >(wc -c) 只剩命令自身输出 #2196's output pass): unserved Input/ReadWrite positions materialize stream-first (/dev/fd/Nword, live endpoint recorded by position) with the timed collection as spawn-failure fallback; theredirect_inarm now records its served position in both branches so its entry is never materialized twice.procsub_spawn_plan's Input arm prefers the streamed endpoint for prefix bindings.apply_external_stdin_redirectreplays the command's own list (own_numbered_input_binding) — last earlier binding wins, opened once, stashed inown_input_bindings;spawn_external_processstamps/pins that same description at N (dup2 shape) and gains an alias arm binding/dev/fd/Mtargets to M's File endpoint via the command-level numbered fd redirection is not delivered to external children (child sees EBADF) #1686 channels.open_compound_numbered_input_redirects,read_redirected_fd,mapfile_redirected_fd_inputresolve alias targets through the fd table (/dev/fd/63 redirect family on synthetic fds: double diagnostic, wrong shapes for < and <>, >> silently succeeds rc=0 #1963 layer) instead of a filesystem open of the spelling.Verification
tests/issue2235_list_input_procsub_regressions.rs: 11 pins — 8 numbered cells red on master bbd95e3, all green with this change; 3 controls (exec / group /{var}) green on both.cat 3<seed <&3 | wc -cfamily) — pipeline stage runners do not run the ordered own-list application at all; recorded as a residual for a separate pipeline-stage pass.issue_1646module (4/4). Fulltests/regression.rsrun (217 passed / 7 failed): 4 reds adjudicated —issue_1584/issue_1900_a4(red on master too in this environment) and two timing-sensitive tests (issue_1951,issue_1952_bang_wait) that pass on both builds in isolation; the other 3 reds (one visible:win_face_fd_history::issue_1888_errors10_sub_verbatim) were not captured by name and are not adjudicated against master — per the compile-rationing order, that comparison belongs to the integration-side batch compile before merge.issue_1903/issue_2225arecfg(windows)(0 local cases) — their verdict rides this PR's Windows goldens job.Not in this PR
#2234 (chained output procsub) is design-only by brief: the live-pipe cascade design, GNU truth table, and a pins-ready draft are in the cluster report; no code, per the contained-or-design rule.