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

Re: PATCH: test for trap EXIT fix.



On Oct 1,  1:01pm, Peter Stephenson wrote:
}
} The comment notes the following behaviour:
} 
} fn() { 
}   ( trap 'print This is in the top-level function scope.' EXIT
}     exit
}   )
} }

Wait ... why is that trap at the top-level function scope?  It's inside a
subshell.  Shouldn't the subshell be its own scope?

Anyway, that behavior is not consistent with previous versions of zsh,
even 4.0.x, so we should think about it pretty carefully.

} The subshell exits without ever leaving the scope of fn(), so the EXIT trap
} isn't called in this case.

Hrm.  Try these variants (with `fn' as above):

zsh% trap 'print PS1-level' EXIT; fn 			#1
zsh% (trap 'print PS1-level' EXIT; fn)			#2
zsh% trap 'print PS1-level' EXIT; (exit)		#3
zsh% function TRAPEXIT { print PS1-level }; (exit)	#4
PS1-level
zsh% function TRAPEXIT { print PS1-level }; fn		#5
zsh% 

What's the excuse for the PS1-level trap not running any case but #4?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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