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

Re: trap does not work in a trap function?



On Thu, 9 Sep 2010 11:44:49 +0200
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> Could you also use "SIGEXIT() shutdown" and "unfunction SIGEXIT"
> instead, regardless of the amount of function nesting? (It seems to
> work when I try it).

What's supposed to happen is the trap, however it is set, is saved and
unset during the function, then restored afterwards (before the scope in
which the function's EXIT trap is run, hence the workaround).  So this
isn't supposed to work.  I get the following:

% TRAPEXIT() { echo This is the exit trap; }
% fn() { unfunction TRAPEXIT; }
% fn
fn:unfunction: no such hash table element: TRAPEXIT
% functions TRAPEXIT
TRAPEXIT () {
	echo This is the exit trap
}
% exit
This is the exit trap

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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