Skip to content

[bug] DEBUG trap not inherited into command substitution (echo "$(trap 'echo DC' DEBUG; echo x)" loses DC lines) #345

Closed

Description

@caomengxuan666

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

Repro:

echo "$(trap 'echo DC' DEBUG; echo x)"

GNU 5.3.0: DC\nx — a DEBUG trap armed inside a comsub fires for every subsequent command in that comsub.
rubash: x only — the armed DEBUG trap is silently dropped inside the comsub.

Note: ERR traps inside comsub work (cat5 t043 passes), so this is DEBUG-specific inheritance.
GNU C owner: subst.c:7143 command_substitute() — subshell copies the trap state; execute_cmd.c:704/782 DEBUG-trap firing checks in execute_command_internal().
Artifacts: target/issue-suites/results/gnusweep3/cat5/case/t054.; minimal target/issue-suites/results/gnusweep3/probes/min/m11-debug-comsub.

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): DEBUG trap armed inside a subshell fires, and inherited DEBUG resets at subshell entry (trap.c:1588; table-driven debug_trap_in_scope + reset_for_subshell DEBUG/RETURN marking when !functrace).

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