Skip to content

[bug] ERR trap is not inherited into command substitution under set -E (errtrace) #1133

Closed

Description

@caomengxuan666

[bug] ERR trap is not inherited into command substitution under set -E (errtrace)

set -E; trap 'echo ERR-IN' ERR; x=$(false; echo incmd); echo "x=$x"
# GNU bash 5.3.20: x=ERR-IN
#                  incmd        (the ERR trap fires inside the command substitution and is captured)
# rubash / niu:     x=incmd     (no ERR-IN)

Expected (GNU bash 5.3.20): x contains ERR-IN followed by incmd.
Actual (rubash): x contains only incmd.

Inheritance into functions and ( ) subshells works correctly in rubash; only $( ) drops the ERR trap, so errtrace-based error handling silently stops working exactly where commands are captured.

Env: rubash master 493ebb2 / niubash 1.4.4 (niu, master 953f513, embeds rubash 493ebb2), Linux x86_64, GNU bash 5.3.20 x86_64-pc-linux-gnu as oracle. Also reproduces in niu (same engine).

Activity

  1. caomengxuan666 commented on Oct 23, 2026

    @caomengxuan666
    MemberAuthor

    FIXED-BY-#1181 — verified on master (263ce53f). Commit 7a10389.

    set -E; trap 'echo ERR-IN' ERR; x=$(false; echo incmd); echo "x=$x" → x=ERR-IN\nincmd, identical to GNU 5.3.20.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions