Repository navigation
fix(executor): apply {var} redirects up to failing redirect frontier (rubash#3892) - #3902
Merged
Merged
Conversation
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
…ly exec (Refs #3893) fix(executor): bind {var} heredoc at its list position in redirect-only exec (Refs #3893) Root cause: in `execute_stdio_only_exec_redirect` (src/executor/trap_exec.rs), the walk consumed a `{var}<<` / `{var}<<<` heredoc twin and then called `execute_dynamic_fd_var_redirect`, which has no HereDoc/HereString arm — a pure no-op apart from the readonly check. The real bind happened in the tail loop, after every later entry's undo-save had already claimed its slot (`exec 14<<X {v}<<A 14<<B` gave `v=11`, GNU gives `v=10`). The walk now binds the heredoc at its list position via `execute_dynamic_fd_var_heredoc` and the tail loop binds only twins the walk did not consume. GNU anchors (bash 5.3, redir.c): :237 `do_redirections` single ordered walk; :1065 heredoc/here-string arm, `here_document_to_fd` at :1072; :1082/:1113 REDIR_VARASSIGN F_DUPFD + bind; :1091 later undo-save lands after the var's allocation. Oracle matrix (6 shapes, vendored 5.3.20) all match. Verification (captain-adjudicated, REPORT ~/workspace/fix-3893/REPORT.md): - Pins tests/issue3893_exec_var_heredoc_fd_allocation.rs (6 pins): fail-first 3 red / 3 green on base bb27eb2 (`v=11` vs expected `v=10`), 6/6 green after the fix — on server legs AND on this head's CI census (6/6 PASS). - Adjacent stems green: issue3578 14/14, issue3578-dual 6/6, issue1313 2/2, issue3195 19/19; lib 1280/0; RUSTFLAGS="-D warnings" rc=0; rustfmt clean; marker-literals + utf8-boundary hygiene clean. - Head census total 82 (era band 79–88), net −3 vs tip (85). New cells vs tip: 2× issue3640 (exec-3/4 fd landing) — PROVEN census jitter by captain isolation: the stem passes 7/7 on both the base tree and this head's tree on the server; 1× issue2333 carrier + 1× issue2883 prompt, both on faces this diff cannot reach (flake standard). issue3316 cell still red on the head census — known fixture defect, reopened as #3316, separate lane. - Goldens job: exactly the 2 baseline names. CLI job: exactly the one pre-existing cell (compat_issue78, #3899 — fixed by pending #3903). - Guard: no file collision with open PRs (#3538/#3398 touch script_driver.rs only; #3902 also touches trap_exec.rs but different hunks — it rebases after this merge). 本 PR 删除了什么: - 删除了 `execute_stdio_only_exec_redirect` 里 `{var}` heredoc 只在 tail loop 滞后绑定的旧路径(walk 已消费的 twin 不再走到 tail 绑定)。 - 删除了 fd_var 分支里对 heredoc 条目调用无 HereDoc/HereString 臂的 `execute_dynamic_fd_var_redirect` 所产生的无操作调用(该调用对 heredoc 除只读检查外什么都不做)。 - 未删除任何公开 API、测试或产品行为;funnel 面 `apply_dynamic_fd_var_redirects` 的同类分裂限制未动,已另立 #3906 跟进。 UNVERIFIED-BY-CAPTAIN — captain review: PASS. Merge by captain; #3893 to be hand-closed by the captain after merge (Refs-only body, no auto-close).
This was referenced Nov 18, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
#3906) ## Summary Guard nail for rubash #3906 (funnel face: `{var}` heredocs applied after the plain list, not at list position). The defect itself was already removed by PR #3902 (9fd2619); this PR lands the 6-cell nail as a regression guard, test-only, no product change. **Fail-first (server legs, fix-3906/REPORT.md §5):** 6/6 green on tip f983851; 5/6 on the pre-#3902 base 21a6f69 — the leftover-open shape (`exec 14<<P 15<<Q` then `: {v}<<A 14<<B`) goes `v=11` there vs GNU's `v=10`. The other five shapes were already green on base (§5.1 explains why: heredoc entries record as Unmodelled, so no save claims the slot except via the ambient table in the leftover shape). **GNU anchors:** redir.c:237 (`do_redirections`, single ordered walk), :1065 (heredoc arm), :1082/:1113 (REDIR_VARASSIGN bind). Expectations byte-verified against GNU bash 5.3.20 script-file probes. Refs #3906 ## 本 PR 删除了什么 无。 <!-- UNVERIFIED-BY-CAPTAIN: head CI (census/goldens/CLI) pending captain adjudication; server legs per REPORT §5. --> ## 队长复核(头 f4a875e,run 44364505753) - 自带钉 issue3906 **6/6 绿**;census 78,相对尖集唯一多出为 issue2340 bare_wait(wait/jobs 已知抖动族;本 PR 仅新增一个测试文件,不可达)。 - goldens 仅基线二名;CLI 仅已知 coproc 抖动格;其余腿全绿。 - 文件面 = 仅新增 tests/issue3906_funnel_var_heredoc_list_position.rs,与基底以来全部合入零交集,免 update-branch 直接合。
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.
Fixes #3892.
Summary
heredoc_redirectswithcmd.redirectsin list order insideapply_dynamic_fd_var_redirectsand stop at the first failing non-{var}redirect (non_fd_var_redirect_fails_at), matching GNUdo_redirections+undo_partial_redirectssemantics where{var}entries before the failing redirect survive (unlessvarredir_close) and{var}entries after it never run.execis rejected byreject_invalid_redirectsorpregate_redirect_open_checkincommand_dispatch.rs, apply{var}redirects up to the failing redirect frontier withauto_close = false.tests/issue3892_exec_varassign_no_undo.rs.Verification
rustfmt --edition 2021 --checkon touched files: passcargo test --locked --test "issue3892*" --test "issue3195*" --test "issue3578*": 48 passed (10 + 18 + 6 + 14), 0 failed