Skip to content

[bug] ERR trap is not executed when set -e terminates the shell on a failing command #344

Closed

Description

@caomengxuan666

Found by gnusweep3 lane (cat5 t041; WSL GNU Bash 5.3.0 oracle, worktree 0fe8d0f).

Repro:

set -e
trap 'echo E' ERR
false
echo unreachable

GNU 5.3.0: prints E, rc=1 — the ERR trap fires for the failing command before errexit kills the shell.
rubash: no output at all, rc=1 — silent death.

GNU C owner: execute_cmd.c — run_error_trap() calls at execute_cmd.c:773/874/1000/1166 precede the errexit exit path in execute_command_internal() (execute_cmd.c:624).
Artifacts: target/issue-suites/results/gnusweep3/cat5/case/t041.; minimal target/issue-suites/results/gnusweep3/probes/min/m10-err-errexit.

Activity

  1. added
    bug
    gnu-baseline
    on Sep 30, 2026
  2. added a commit that references this issue on Sep 30, 2026
  3. caomengxuan666 commented on Sep 30, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt20/deepsweep (536abb86): ERR trap runs BEFORE errexit kills (run_error_trap execute_cmd.c:1000/1166 ordered before ERREXIT :624; fixed at the dispatch conversion site and ast_exec ordering).

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

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions