Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to trap EXIT like in bash
On Sat, Apr 04, 2015 at 11:35:57AM -0700, Bart Schaefer wrote:
> Hmm. This seems to be a side-effect of the rule that the EXIT trap does
> not run from inside other traps. The default response to INT in a script
> is to behave as if 'trap "exit 130" INT' so the EXIT trap is not run. In
>
> Curiously in an interactive shell, the following prints "trapped" exactly
> one time, even though my first answer above also works interactively:
>
> trap "echo trapped" EXIT
> trap exit HUP INT TERM
>
> However, that does not work in a script. I'm not sure why interactive
> matters here.
I think because the rule that EXIT trap doesn't run from inside other
traps, the phenomenon of script not working is correct and the
interactive shell working is wrong.
Am I right?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author