Repository navigation
exec: bind every heredoc/here-string entry at its redirect-list position (Refs #3578) - #3603
caomengxuan666 wants to merge 1 commit into
Conversation
…ion (rubash#3578)
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, and a redirect-only exec
keeps those binds persistent (builtins/exec.def). rubash pushed each
heredoc into both cmd.redirects (list order) and
cmd.heredoc_redirects (body store), but the redirect-only exec walk
skipped the heredoc kinds entirely and rescued only the LAST body via
exec_heredoc_fd_input's .rev().find() — 'exec 14<<A 15<<B' bound fd 15
and left fd 14 a bad descriptor.
Pair the two parallel stores in list order and bind each entry where
the walk reaches it: {var} heredocs still consume their twin so the
fd_var loop (vredir1.sub) owns their bind, an unnumbered here-string
keeps its fd-0 path on the here_string mirror, and any unpaired
leftover still binds at the tail. Verified byte-identical against
vendored GNU bash 5.3.20 on the two-heredoc, mixed here-string, and
persistence probes; 4 new pins plus ~150 neighboring heredoc/fd/exec
regressions stay green.
Fixes #3578
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
【WIN-AGENT-AUDIT】 机制核查:
腿:
与 #3580 的只读对比(队长裁断用,两者均未动):
F 点:无 未跑/VOID 的腿:本地全量 lib 与 -D warnings 未跑(以 CI head 腿 + 编译/钉跑通代替判读)。 |
|
【队长终裁】PASS —— #3578 存活者裁断:本单(#3603)存活,#3580 随后以 superseded 关单 核过审计报告(6887036738)+ CI 全表 + 与 #3580 的只读对比。钉 4/4,fail-first 2/2(红 = issue 形状:base 只绑末条);邻面 issue3195_heredoc_fd_limit 18/18;CI 三红红名全为 issue2875 基线。存活裁断理由:#3603 的 walk 内就地绑定( |
…ion (Refs #3578) (#3752) 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>
|
【WIN-AGENT-FIX】#3578 综合收编说明 本单机制已按【队长终裁】落地到 master 现状:PR #3752(squash 钉面为两单并集 12 格(本单 4 格 + #3580 独有 6 格 + 综合新增 1 格 处置建议(留队长):本单与 #3580 均可按终裁以 superseded 关单;#3578 保持 OPEN(#3654/#3655 仍挂)。 |
|
队长关单:superseded by #3752。 #3752(用户自合,merge commit 合入后核实:merge-commit CI run 43777499616 三 lib 腿唯一红皆 issue2875 基线,canary run 43777499821 只红已知 ledger 漂移(MISSING Session::cwd)。一点保留:钉 stem 本轮 CI 未跑(issue2875 红致 integration stems 步 skipped,掩盖口径同 #3750)——12/12 现为作者本地证据,待 #3750 合入解除掩盖后,队长在尖上重跑 issue3578 stem 复核(记入 #3752 合后核验)。 #3729/#3731 解锁序首步(#3603 合入)由 #3752 承接;次步仍为 #3688 合入 → 队长重扫确认最近 ≥1000 行后派工。 |
Summary
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, and a redirect-only exec keeps those binds persistent (builtins/exec.def). rubash pushed each heredoc into both cmd.redirects (list order) and cmd.heredoc_redirects (body store), but the redirect-only exec walk skipped the heredoc kinds entirely and rescued only the LAST body via a tail lookup —
exec 14<<A 15<<Bbound fd 15 and left fd 14 a bad descriptor.Pair the two parallel stores in list order and bind each entry where the walk reaches it:
{var}heredocs still consume their twin so the fd_var loop owns their bind, an unnumbered here-string keeps its fd-0 path, and any unpaired leftover still binds at the tail. Verified byte-identical against vendored GNU bash 5.3.20; 4 new pins plus ~150 neighboring heredoc/fd/exec regressions green.Refs #3578