On Tue, Oct 16, 2012 at 1:26 PM, Francis Moreau <francis.m...@gmail.com> wrote: > Hi, > > Currently the description of the builtin trap isn't enough regarding > the description of the EXIT signal spec, IMHO. > > It says: "If a SIGNAL_SPEC is EXIT (0) ARG is executed on exit from > the shell.", and nothing more, unless I'm missing some other points > about it somewhere else (that would be unfortunate too). > > Specifically, the documentation should specify exactly what "exit from > the shell" means: for example killing a shell process makes it exit > somehow. Is this is supposed to be handled by EXIT signal spec ? > > Another thing that should be clarified is what's happening in the > context of a subshell ? > > Thanks > -- > Francis >
Anything that causes the shell to exit will trigger the trap (with the exception of signals that can't be handled, like KILL). That means a normal "exit" command or hitting EOF will trigger it, but so will TERM, or INT, etc. What about subshells do you not understand? If the trap is defined within a subshell, it will trigger when that subshell exits. If it's defined outside, it will not.