Skip to content

set -E ERR-trap edge cases: nested subshell fire count, f() ( ) flat region, process substitution, return-in-until attribution #720

Closed

Description

@caomengxuan666

Summary

Four pre-existing set -E / ERR-trap divergences found (and deliberately not fixed) while verifying PR #719 (rubash#702). Filing so they stay tracked; each has a byte-verified GNU comparison (D:/Git/bin/bash.exe 5.2/5.3).

case rubash (PR #719 branch) GNU
set -E; trap 'echo ERR' ERR; ( (false) ) fires 3 fires 2 (nested subshell as first body command over-fires; GNU suppresses the middle level)
set -E; trap 'echo ERR' ERR; f() ( false ); f fires 2 fires 3 (flat f() ( ) region misses one level-0 fire)
set -E; trap 'echo ERR' ERR; cat <(false) differs from GNU process-substitution copy path (shares the read/procsub area — PR #715 touched the read side)
set -e; trap 'echo ERR:$?' ERR; f(){ return 7; }; until false; do f; done condition's stale status attributed to f (same mechanism as #702 R4.1, different command: return also unwinds via Err) ERR fires for the failing body command, semantic differs

Notes

Activity

  1. added
    bug
    family:S8
    family:S9
    on Oct 17, 2026
  2. caomengxuan666 commented on Oct 18, 2026

    @caomengxuan666
    MemberAuthor

    Fix train: PR #831 (branch fix/720-713)

    Three of the four forms are fixed and byte-pinned against WSL GNU bash 5.3.0(1) (stdin oracle; 12-case regression file tests/issue720_err_trap_nested_context_regressions.rs):

    form was now
    1. ( (false) ) fire count 3 2 — GNU fork-collapses a user subshell whose whole body is a single subshell command (execute_cmd.c:1799-1806 + :662-663): the middle frame never waits, so no :769 fire. Non-collapsed middles (( (false); false ), ( { (false); } )) still fire, per GNU.
    2. f() ( false ); f fire count 2 3 — the flat region now runs the wait-side completion fire (execute_cmd.c:756-778): $LINENO = the region's ) line (execute_cmd.c:696), BASH_COMMAND = the region text ( false ) (the :703-710 fork-preamble the_printed_command_except_trap).
    4. return-in-until attribution ERR:1/exit 1 ERR:7/exit 7 — the dispatcher gate no longer consumes Err(Return) with the loop condition's stale status; the function boundary stamps exit_code = N and the call's gate adjudicates.

    Form 3 (cat <(false)) remains open — it is the procsub/read-reaping area (PR #715's seam), deliberately not fixed here. The audit train also extended scripts/audit/nested-context-probes.py to 45 cases and filed #825/#826 from the same pass (#713).

  3. caomengxuan666 commented on Oct 18, 2026

    @caomengxuan666
    MemberAuthor

    由 #831 修复落地(复核轮二 APPROVE-WITH-NITS):三形态 ERR-trap 修复(子壳折叠 CMD_NO_FORK 精确圈定/扁平函数 close_flat_region 覆盖含 Ok(Some) 管道与 catch-all/Return 归因不吞 Err)+ 同类扩展两处(brace Ok(true)/早派发 catch-all 统一 close-before-return)+ 状态泄漏归零(BASH_SUBSHELL 序列与 GNU 逐字节)。17/17 回归、14 形态电池 IDENTICAL、issue797 8/8(#807 无回退)。残余两处未盖路径预存不阻塞(其一建议并入 #826)。#713 审计交付=两新票 #825/#826。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfamily:S8family:S9

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions