You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug] Command substitution captures nothing when the substituted program is the rbenv dispatcher script (output leaks to real stdout): rbenv init eval chain defines no function #193
Minimal reproducer (narrower than the rbenv chain — the trigger is a VARIABLE first word in the comsub, which routes the body through the full-parser path instead of the external spawn fast path):
rubash before: pre captured, sort --version output LEAKED to the real stdout, x=[pre]. Literal $(./s2.sh) captured fine — only the variable-first-word form leaks.
GNU anchor:builtins/exec.def exec_builtin → shell_execve (execute_cmd.c:6126-6159): the exec'd program inherits fd 1, which inside a comsub (subst.c:7143 command_substitute) is the capture pipe.
Root cause: rubash runs such scripts in-process on the full-parser comsub path, where fd 1's Stdout endpoint resolves to the in-memory stdout_capture — no inheritable OS handle. execute_exec's default arm translated that endpoint to Stdio::inherit() = raw process stdout. Fix: when fd 1's endpoint is Stdout and a capture is active, run the exec'd child piped via execute_with_io and forward through the capture-aware GlobalStdout (same shape as run_external_command_substitution); exec cmd 2>&1 in the substitution joins the capture, plain fd 2 stays the terminal. Non-capture arms unchanged.
Verification (WSL GNU Bash 5.3.0):x="$($L --version)" → v=[rbenv 1.3.2] len=11 (the expected output in this issue); rbenv init - bash stage-1 captured (p02 shape); exit statuses for exec false (1) / exec missing (127, diagnostic captured under 2>&1) identical to GNU. Suites comsub/comsub-eof/comsub2/dstack/dstack2/errors ledger unchanged (25/0/66/0/0/2). The one d-len byte difference in the sort probe is WinuxCmd sort 8.32 vs WSL coreutils 9.4 version text — environment artifact, not a divergence.
Activity
caomengxuan666 commentedon Sep 27, 2026
更正(上文两处内联替换在提交时被本地 shell 吃掉):
$(echo nested)—— OK。resolved_path="$("$readlink" -f "$1")"。caomengxuan666 commentedon Sep 27, 2026
Fixed on
wt/p3-comsub(b0728d30, base 26728da).Minimal reproducer (narrower than the rbenv chain — the trigger is a VARIABLE first word in the comsub, which routes the body through the full-parser path instead of the external spawn fast path):
rubash before:
precaptured,sort --versionoutput LEAKED to the real stdout,x=[pre]. Literal$(./s2.sh)captured fine — only the variable-first-word form leaks.GNU anchor:
builtins/exec.def exec_builtin→shell_execve(execute_cmd.c:6126-6159): the exec'd program inherits fd 1, which inside a comsub (subst.c:7143 command_substitute) is the capture pipe.Root cause: rubash runs such scripts in-process on the full-parser comsub path, where fd 1's Stdout endpoint resolves to the in-memory
stdout_capture— no inheritable OS handle.execute_exec's default arm translated that endpoint toStdio::inherit()= raw process stdout. Fix: when fd 1's endpoint is Stdout and a capture is active, run the exec'd child piped viaexecute_with_ioand forward through the capture-awareGlobalStdout(same shape asrun_external_command_substitution);exec cmd 2>&1in the substitution joins the capture, plain fd 2 stays the terminal. Non-capture arms unchanged.Verification (WSL GNU Bash 5.3.0):
x="$($L --version)"→v=[rbenv 1.3.2] len=11(the expected output in this issue);rbenv init - bashstage-1 captured (p02 shape); exit statuses forexec false(1) /exec missing(127, diagnostic captured under 2>&1) identical to GNU. Suites comsub/comsub-eof/comsub2/dstack/dstack2/errors ledger unchanged (25/0/66/0/0/2). The oned-lenbyte difference in the sort probe is WinuxCmd sort 8.32 vs WSL coreutils 9.4 version text — environment artifact, not a divergence.caomengxuan666 commentedon Sep 27, 2026
已在 9ecb59b 落地并关闭(三 commit 已在 issue 评论区有独立说明)。477/477 + 双交叉 + 套件账本零回归。