Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: EXIT trap executes too late?Re: stuff
- X-seq: zsh-workers 17274
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx (Zsh hackers list)
- Subject: Re: EXIT trap executes too late?Re: stuff
- Date: Sun, 02 Jun 2002 19:10:38 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Bart wrote:
> "The functions beginning `TRAP' may alternatively be defined with the
> trap builtin: this may be preferable for some uses, as they are then
> run in the environment of the calling process, rather than in their own
> function environment."
>
> That doesn't appear to be true for the EXIT trap:
You're missing this (second paragraph of the texinfo node Functions):
Functions execute in the same process as the caller and share all files
and present working directory with the caller. A trap on EXIT set
inside a function is executed after the function completes in the
environment of the caller.
So `the environment of the calling process' in the first quotation is
the environment which called the function for which the exit trap is
set, not the function where the exit trap is defined. So it's doing
it's job properly (and indeed it was to ensure this behaviour that I
tinkered with execsave()/execrestore()). However, this is confusing
because of the way `environment of the caller' has two meanings and the
documentation could probably be clearer.
--
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk
Messages sorted by:
Reverse Date,
Date,
Thread,
Author