Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: trap for EXIT doesn't catch exit?

Bart Schaefer wrote:
> I don't think it's sufficient to simulate exiting the scopes, because the
> traps have to execute as if they're in the scope where they were installed.
> It may be necessary to actually unwind the stack; at least it's necessary
> to call endparamscope() and endtrapscope() the correct number of times.

Yes, that eventually occurred to me.

> We may want to bring this up on the shell@xxxxxxxxxxxxxxxx list.

Possibly a good idea, but the other shells' behaviour, having an exit trap
only for the shell, already seems to be standard.  We would need to treat
it specially as an option.  It's a bit of pain because this works

18:34% ksh
$ foo() { trap 'echo exit' EXIT; }
$ foo
$ exit

while most (or maybe all) other traps in ksh are local.  That is, at least,
an argument for our way of doing it.

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070

The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
If you received this in error, please contact the sender and 
delete the material from any computer.

Messages sorted by: Reverse Date, Date, Thread, Author