On Thu, Nov 29, 2018 at 04:02:32PM +0100, Martijn Dekker wrote:
>
> Isn't it much simpler than that? Upon forking a subshell, traps are reset,
> so it would make sense that any flag that says "we are currently in the
> process of executing a trap" is also reset.
>
> Which, from a look at the source code, seems to be the -1 value of
> savestatus. So this oneliner fixes it for me:
>
> diff --git a/src/trap.c b/src/trap.c
> index ab0ecd4..7740955 100644
> --- a/src/trap.c
> +++ b/src/trap.c
> @@ -168,6 +168,7 @@ clear_traps(void)
> }
> }
> trapcnt = 0;
> + savestatus = -1;
> INTON;
> }
Hmm, I think this breaks the following case which used to work:
dash -c 'trap "(:; exit) && echo BUG" EXIT; false'
I know this makes no sense but almost every other shell does it
this way.
Thanks,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt