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] declare -p NAME not-found diagnostic is empty inside a command substitution (top-level matches GNU) #189
WSL GNU Bash 5.3.0: captured=[<script>: line 2: declare: ZZQ: not found]
rubash c9bd0af: captured=[] (diagnostic neither captured nor printed)
Top-level declare -p ZZQ (not in comsub) matches GNU byte-for-byte (<script>: line 2: declare: ZZQ: not found, rc 1). Only the comsub-context diagnostic is dropped, so this looks like the fd-2 endpoint routing family of #167 but for the declare builtin path.
Found while verifying #163 close-out (matrix F1 in target/o2/lang163-matrix.sh, worktree wt/o2-parser). GNU anchor: builtins/declare.def declare_builtin error path sh_notfound/proclists error -> stderr, which inside a comsub is the captured pipe.
GNU anchor:declare.def:388-404 (pflag loop) → sh_notfound (builtins/common.c:188) → builtin_error (common.c:98-108) vfprintf's to stderr — inside a comsub that fd is inherited (terminal) or, after body-level 2>&1, the capture pipe. GNU never drops it.
Root cause:execute_declare (src/executor/declare_local.rs) carried a guard from the bashdb hardening commit a69937a (no GNU anchor) that replaced the buffered stderr with an empty Vec whenever stdout_capture was active + print mode + non-zero status — exactly the comsub shape, so the diagnostic vanished both with and without 2>&1. Guard removed; the buffer now routes through write_buffered_builtin_output, which resolves the command's fd-2 endpoint.
Verification (WSL GNU Bash 5.3.0, LF script both sides):V=$(declare -p ZZQ 2>&1) captures <script>: line 2: declare: ZZQ: not found; plain V2=$(declare -p ZZQ) prints it on real stderr (line 4) — stdout/stderr byte-identical to GNU. Suites comsub/comsub-eof/comsub2/builtins ledger unchanged (25/0/66/7 before and after).
Activity
caomengxuan666 commentedon Sep 27, 2026
Fixed on
wt/p3-comsub(026eef32, base 26728da).GNU anchor:
declare.def:388-404(pflag loop) →sh_notfound(builtins/common.c:188) →builtin_error(common.c:98-108) vfprintf's to stderr — inside a comsub that fd is inherited (terminal) or, after body-level2>&1, the capture pipe. GNU never drops it.Root cause:
execute_declare(src/executor/declare_local.rs) carried a guard from the bashdb hardening commit a69937a (no GNU anchor) that replaced the buffered stderr with an empty Vec wheneverstdout_capturewas active + print mode + non-zero status — exactly the comsub shape, so the diagnostic vanished both with and without2>&1. Guard removed; the buffer now routes throughwrite_buffered_builtin_output, which resolves the command's fd-2 endpoint.Verification (WSL GNU Bash 5.3.0, LF script both sides):
V=$(declare -p ZZQ 2>&1)captures<script>: line 2: declare: ZZQ: not found; plainV2=$(declare -p ZZQ)prints it on real stderr (line 4) — stdout/stderr byte-identical to GNU. Suites comsub/comsub-eof/comsub2/builtins ledger unchanged (25/0/66/7 before and after).caomengxuan666 commentedon Sep 27, 2026
已在 9ecb59b 落地并关闭(三 commit 已在 issue 评论区有独立说明)。477/477 + 双交叉 + 套件账本零回归。