From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14525 invoked from network); 2 Jun 2002 18:10:00 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 2 Jun 2002 18:10:00 -0000 Received: (qmail 6462 invoked by alias); 2 Jun 2002 18:09:52 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17274 Received: (qmail 6440 invoked from network); 2 Jun 2002 18:09:51 -0000 To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: Re: EXIT trap executes too late?Re: stuff Date: Sun, 02 Jun 2002 19:10:38 +0100 From: Peter Stephenson Message-Id: <20020602181043.130A61C0B4@pwstephenson.fsnet.co.uk> 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 Work: pws@csr.com Web: http://www.pwstephenson.fsnet.co.uk