Antonio Ospite <ao2@xxxxxx> wrote: > 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 <ao2@xxxxxx> > --- > > Hi, > > this has been reported in Debian[1] and I noticed the issue myself too, so > I tried to take a look at it. > > I am marking the patch as RFC because I don't know the dash codebase very > well, and I might not be aware of possible drawbacks of this change. It worked > in my limited testing but that's it. > > I don't know if the behavior of traps is specified when "set -e" is active, > but in case it isn't it would stll be good to behave like other shells. > > Any comment is welcome. > > Thank you, > Antonio > > > [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=779416 > > > src/eval.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Patch applied. Thanks. -- Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt