Op 29-11-18 om 21:39 schreef Harald van Dijk:
By the way, my change has an unintended but possibly acceptable side
effect:
trap '(trap "echo exit" EXIT; :)' EXIT
This prints nothing with current dash, but prints "exit" with my change.
It also prints "exit" in ksh, mksh, posh, and bosh.
IMHO, that's not a side effect, but evidence that the bug was properly
fixed. A subshell is defined as a duplicate of the original shell
process except with its traps reset[*], so setting a trap should work as
normal within it.
It doesn't work in bash, yash or zsh, which I believe is a bug that I
should report to them.
- M.
[*] "A subshell environment shall be created as a duplicate of the shell
environment, except that signal traps that are not being ignored shall
be set to the default action."
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_12
(I'm going to assume that "signal traps" here is meant to include the
EXIT trap, because not clearing it for subshells would be insane.)