# hello, control, been a while... tag 683671 + patch fixed-upstream thanks Hi Andrej et al.,
After independently encountering and then debugging this problem to the point where I had a fix, I learned that Antonio Ospite had come up with an identical one (modulus whitespace) over a year ago[1]. I've attached a copy. It really sucks that dash has had this bug for 12 years, given that: 1. It's Debian's default /bin/sh; 2. We're required by Policy to 'set -e' in our maintainer scripts[2]; and 3. Script authors generally don't write signal handlers for fun--they do it because they need to clean up or roll back some activity, and this bug utterly frustrates their efforts. Were I active in the project, I'd be raising hell like in the old days to get this bug's severity back up to 'serious', on the premise that it frustrates the robustness of maintainer scripts that we try to ensure with 'set -e' in the first place. The fix is a transposition of one line; please consider applying it. I notice there are other fixes in the git repo, also usually from Antonio Ospite, for various compiler warnings. Those may be worthy of consideration in a near-term package release as well. Cheers! [1] https://git.kernel.org/pub/scm/utils/dash/dash.git/commit/?id=06204f0c9f539fcb8cb532166656e80b81bd689a [2] https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html -- G. Branden Robinson Trustworthy Systems Group, CSIRO's Data61 "Every good idea will be discovered twice: once by a logician and once by a computer scientist." - Philip Wadler
commit 06204f0c9f539fcb8cb532166656e80b81bd689a Author: Antonio Ospite <a...@ao2.it> Date: Tue Oct 16 14:09:52 2018 +0200 eval: make traps work when "set -e" is enabled When "set -e" is enabled traps are not always executed, in particular the EXIT trap is not executed when the shell exits on an unhandled error. Consider the following test script: #!/bin/dash set -e trap 'ret=$?; echo "EXIT: $ret"' EXIT trap 'exit 2' HUP INT QUIT PIPE TERM read variable By pressing Ctrl-C one would expect the EXIT trap to be called, as it is the case with other shells (bash, zsh), but dash does not do it. By calling dotrap() before jumping to the exit path when checkexit is not zero, dash behaves like other shells. Signed-off-by: Antonio Ospite <a...@ao2.it> Signed-off-by: Herbert Xu <herb...@gondor.apana.org.au> diff --git a/src/eval.c b/src/eval.c index 546ee1b..dde9fa2 100644 --- a/src/eval.c +++ b/src/eval.c @@ -307,11 +307,11 @@ setstatus: break; } out: + dotrap(); + if (checkexit & status) goto exexit; - dotrap(); - if (flags & EV_EXIT) { exexit: exraise(EXEXIT);