Repository navigation
exec: bind every heredoc/here-string entry at its redirect-list position — #3603+#3580 synthesis (Refs #3578) - #3752
Merged
Conversation
…ion (Refs #3578) Synthesis of PR #3603's mechanism and PR #3580's wider pin grid for issue #3578 (captain's survivor ruling: #3603's in-walk pairing wins on mechanism fidelity; #3580's extra pin cells re-verified on the merged shape). GNU applies each redirect in do_redirections' list order — here_document_to_fd (redir.c:423) materializes the body and dup2s it onto the redirector at redir.c:1065-1072/:1120, and a redirect-only exec keeps those binds persistent (builtins/exec.def). The parser mirrors every heredoc / numbered here-string into both cmd.redirects (its list position) and cmd.heredoc_redirects (its body store), but the redirect-only exec walk skipped the heredoc kinds entirely and the tail lookup bound only the LAST body — `exec 14<<A 15<<B` left fd 14 unbound. Pair the two parallel stores in list order (heredoc_twins): {var} entries consume their twin so the fd_var heredoc loop keeps owning their bind (vredir1.sub), an unnumbered here-string keeps its fd-0 here_string path, and any unpaired leftover still binds at the tail. The #3195 rlimit gate still aborts the whole walk before any bind. Expansion goes through the canonical expand_heredoc_redirect_text ladder — the same bytes execute_dynamic_fd_var_heredoc binds — replacing the deleted exec_heredoc_fd_input tail lookup. Pins (tests/issue3578_exec_multi_heredoc.rs, 12 cells): #3603's four plus #3580's union-unique cells (read -u two-heredoc seed, three heredocs, same-fd last-wins, fd-0+numbered, {var}+numbered, brace-group control) plus an interleave pin for the at-position bind itself (exec <<A 3<&0). Every expectation byte-verified against WSL GNU bash 5.3.x script-file probes. Refs #3578 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This was referenced Nov 15, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
…3578) (#3895) The core fix already landed via #3752 (b69e175): the exec redirect walk pairs each numbered heredoc/here-string entry with its heredoc_redirects twin at its own list position (GNU redir.c do_redirections ordered walk, here_document_to_fd materialization). This adds dedicated regression pins for the under-limit class the issue title describes — exec 14<<A 15<<B under ulimit -n 16 — plus boundary variants: multi-line bodies, reversed fd order, three heredocs at the boundary, heredoc+here-string mix, and persistence into the next command. Byte-identical to WSL GNU Bash 5.3.20 on all six scripts. Residuals found during review filed separately: #3892 (exec {var} binds lost on later-entry failure — GNU varassign entries carry no undo record, redir.c:972/1091/1153), #3893 ({var}<< allocation deferred to walk tail), #3894 ({var}<< body double-bound to fd 0 on simple commands). Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
综合来源(captain 可直接合)
本单是 issue #3578 双实现的综合收编,按 #3603 上的【队长终裁】PASS 裁断落地:
fix/3578-exec-multi-heredoc,head4b589f12):redirect-onlyexec的 walk 内按位配对cmd.redirects↔cmd.heredoc_redirects孪生(heredoc_twins),每条 heredoc/编号 here-string 在自己的 GNU do_redirections 位置 materialize 并绑定(redir.c:423here_document_to_fd+ redir.c:1065-1072/:1120dup2)。{var}<<消耗孪生、绑定仍归 walk 后 fd_var heredoc 循环(vredir1.sub);无编号<<<走既有here_stringfd-0 路径;未配对残余在尾部绑定。master 已大幅前进(rlimit 门 rubash#3195、fd_var heredoc 独立循环等),机制按现状重接线,展开统一走 canonicalexpand_heredoc_redirect_text,删除尾部单条查找exec_heredoc_fd_input。tests/issue3578_exec_multi_heredoc.rs,12 格):exec: bind every heredoc/here-string entry at its redirect-list position (Refs #3578) #3603 的 4 格为基 + fix(executor): redirect-only exec binds every heredoc entry (Refs #3578) #3580 独有格(read -u双 heredoc 种子形、三 heredoc、同 fd 后胜、fd-0+编号、{var}+编号、brace-group 对照)+ 1 格综合新增(exec <<A 3<&0钉住"按位绑定"本身——3<&0dup 到的是 walk 位置已绑的 body)。每格先经 WSL GNU bash 5.3.x script-file 探针字节级验证再写入。验证
cargo test --lib1351/1352、RUSTFLAGS="-D warnings" cargo build干净。rubash.exespawn fd 投递在本机不落、诊断路径风格断言、coproc 时序),与本 diff 无关:issue2270 8/10、issue2305 6/16、issue2309 12/18、issue1651 2/10、issue3046 7/15、issue2125 1/21、issue2615 1/13、issue1102 1/1、issue2803 1/6、lib issue2084。已知残余(非本单范围,供队长备案)
exec <<<a <<B:GNU 后胜给 fd0=B;本机制(与 exec: bind every heredoc/here-string entry at its redirect-list position (Refs #3578) #3603 一致)将无编号<<<延至 walk 后here_string路径回绑,得 a。系改动前既有的偏离(旧代码同样给 a),非本单回归;若要根治需让无编号 here-string 也按位绑定(redirect.target逐条词可用),建议另立跟进。exec <<<a 3<&0 <<<b同类 fd-0 时序边角,同上。两条旧 PR 的处置建议(留给队长)
705b2f32);fix(executor): redirect-only exec binds every heredoc entry (Refs #3578) #3580 以 superseded 关单(其 7 格钉面已并入本单并 GNU 复验全绿——终裁所述"合并形上 7/7"已满足)。Refs #3578
Generated with Devin