## 来源 rubash#164 验收矩阵(wt/m1-here)排查中发现;基线 c5be7542 重建即复现(stash 验证与 #164 修复无关)。 ## 现象 命令的编号输出重定向(`3>file`)作用在本 shell + `-c` 脚本形态的子进程上时,fd 3 没有进入子进程的 fd 表:`>&3` 在子进程内报 `bash: line 1: 3: Bad file descriptor`,文件为空。GNU Bash 5.3.0 中重定向随 fork 的子进程生效,`N3` 写入文件。脚本文件形态(`"$SH" p3.sh >f`,fd 1)不受影响。 ## 最小复现(m13.sh,LF 落盘双侧脚本文件运行) ```sh SH=${THIS_SH:-bash} "$SH" -c 'echo N3 >&3' 3>k13p.tmp echo "P [$(cat k13p.tmp 2>/dev/null)]" ``` - GNU 5.3.0 (WSL, THIS_SH=/usr/local/bin/bash): `P [N3]`,rc=0 - rubash (wt/m1-here @ c5be7542): `bash: line 1: 3: Bad file descriptor` + `P []`,rc=0 ## GNU 锚点 `execute_cmd.c:5771 execute_disk_command`:fork 的子进程在 `:5884` 以 `do_redirections (redirects, RX_ACTIVE)` 应用整条重定向列表(含编号 fd),随后 exec——fd 3 在子进程全程可见。rubash 的进程内 `-c` 子路径(external_finish.rs execute_same_shell_script/execute_direct_shell_script 一族)未把 `3>file` 之类的编号重定向绑定进子作用域 fd 表(fd 1 的 `>file` 正常,说明仅编号 fd 漏绑)。 ## 产物 - `target/issue-suites/results/childfd-not-bound/`(wt/m1-here): `m13.sh`、`m13.rub.out`、`m13.gnu.out` - 验证命令: `target/debug/rubash.exe m13.sh` vs `MSYS_NO_PATHCONV=1 wsl bash -c "export THIS_SH=/usr/local/bin/bash; bash m13.sh"`(各自 cwd 下) 版本: wt/m1-here @ c5be7542,对照 WSL GNU Bash 5.3.0(1)-release。
Activity
caomengxuan666 commentedon Sep 27, 2026
已在 de86dd5/9b1eb043 修复并关闭(四个独立 commit + captain darwin pipe2 热修)。验收矩阵与双侧产物见各 commit message 及 worktree target/ 探针;套件切片 trap/comsub/redir/attr/func 均 0 diff;474/474 + 双交叉干净。
external: deliver numbered /dev/null redirects to spawned children