set -e reverses order of signal handlers

Bug #892317 reported by Jason Dusek
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dash
New
Undecided
Unassigned
dash (Ubuntu)
New
Undecided
Unassigned

Bug Description

When `-e` is not specified, an INT signal handler runs before an EXIT signal handler; when -e is specified, the EXIT signal handler is run (but only one of its statements) and then the INT signal handler is run.

:; /bin/dash < ./trap.sh
^Ctrapped: SIG_
trapped: EXIT 2
next part
:; /bin/dash -e < ./trap.sh
^Ctrapped: EXIT 130
trapped: SIG_

With `bash --posix` or `busybox sh`, the order of signal handlers is the same no matter whether `-e` is specified or no. Please see the attached script, `trap.sh`.

Revision history for this message
Jason Dusek (solidsnack) wrote :
Revision history for this message
Jarno Suni (jarnos) wrote :

The behavior seems to have changed in later version. I tested dash 0.5.10.2-6.
There EXIT trap is not run at all, if -e is used, and you use Ctrl-C. But if you remove the 'exit 2' from the signal trap, EXIT trap will be run regardless of -e setting, when you press Ctrl-C. That is not intuitive. So I think EXIT trap should be run even in case of -e. However, if you do not need custom exit status for the signal trap, you could just remove the exit builtin.

Revision history for this message
Jarno Suni (jarnos) wrote :

If you can confirm, please update the report.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.