## 复现 ```bash trap "echo OUT" ERR; f() { trap -p ERR; false; }; f; echo rc=$? ``` | | stdout+stderr | rc | |---|---|---| | GNU bash 5.3.0 | `OUT` / `rc=1` | 0 | | rubash 764b9dde | `trap -- 'echo OUT' ERR` / `OUT` / `rc=1` | 0 | ## 根因 未设 `set -E` 时,ERR trap **不**被函数继承:函数体内 trap 上下文为空 → `trap -p ERR` 应无输出(`false` 仍触发外层 trap 打印 OUT,rc=1,这部分 rubash 正确)。rubash 在函数内的 `trap -p` 把继承自外层的 trap 显示了出来——显示态与生效态不一致(生效判定 rubash 是对的:OUT 只打了一次)。 ## 规范/源码依据 - Bash Reference Manual(set -E):"If set, any trap on ERR **is inherited by shell functions**"——反言之未设 -E 不继承。 - bash builtins/trap.def:`trap -p` 显示当前上下文(函数内=函数自己的 trap 表)。 ## 跨实现互证(huck) [huck#438 "Without `set -E`, a function still sees and fires the caller's ERR trap"](https://github.com/jdstanhope/huck/issues/438)(已修复)——同一语义点(-E 缺省时函数不应感知外层 ERR trap);huck 的表现是"会触发"、rubash 的表现是"会显示",均为继承边界漏堵。 ## 证据 - 语料出处:err_trap_function_diff_check.sh:20(F066,label: not inherited) - 复核:764b9dde 仍复现;旧构建 41de8319 行为一致
Activity
fix(wave3): P3 batch — xtrace/redir-message/caller/trap-p/extdebug/sy…
fix: Wave3 P3 batch - xtrace quote fidelity, redirect rendering trio,…
caomengxuan666 commentedon Oct 12, 2026
Fixed by #569 (Wave3). Vendored-bash anchors and RED-then-GREEN regression evidence in the PR.
docs(design): debugger M0 — DAP-over-stdio minimal design (#497) (#582)
Merge pull request #1503 from unixwin/fix/bulk-r3-slice3