[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dash
Subject:    Re: [PATCH] eval: make traps work when "set -e" is enabled
From:       Herbert Xu <herbert () gondor ! apana ! org ! au>
Date:       2018-12-14 5:53:34
Message-ID: 20181214055333.tserbo53hqj2cfja () gondor ! apana ! org ! au
[Download RAW message or body]

Antonio Ospite <ao2@ao2.it> 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@ao2.it>
> ---
> 
> 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@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic