Skip to content

fix(interpreter): fire EXIT trap inside command substitution subshell#854

Merged
chaliy merged 2 commits intomainfrom
fix/issue-806-exit-trap-cmdsub
Mar 26, 2026
Merged

fix(interpreter): fire EXIT trap inside command substitution subshell#854
chaliy merged 2 commits intomainfrom
fix/issue-806-exit-trap-cmdsub

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Mar 26, 2026

Summary

  • EXIT traps set inside $(...) now fire and their output is captured by the substitution, matching real bash behavior
  • Trap state is snapshot/restored so traps set inside $(...) don't leak to the parent shell
  • Previously, EXIT trap output escaped to the parent's stdout instead of being captured

Test plan

  • subst_exit_trap_captured — basic EXIT trap output captured inside $()
  • subst_exit_trap_with_explicit_exit — EXIT trap fires on explicit exit 0 inside $()
  • subst_exit_trap_no_leak — trap output stays inside $(), doesn't leak to parent
  • subst_exit_trap_isolation — parent EXIT trap preserved when $() sets its own
  • Full test suite green (cargo test --all-features)
  • Smoke tested via CLI

Closes #806

chaliy added 2 commits March 26, 2026 22:52
EXIT traps set inside $() now fire and their output is captured by
the substitution, matching real bash behavior. Trap state is
snapshot/restored so traps don't leak to the parent shell.

Closes #806
@chaliy chaliy merged commit b64e9fd into main Mar 26, 2026
23 checks passed
@chaliy chaliy deleted the fix/issue-806-exit-trap-cmdsub branch March 26, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: EXIT trap in command substitution subshell doesn't fire

1 participant