From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10656 invoked by alias); 10 Mar 2014 19:48:26 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18581 Received: (qmail 25203 invoked from network); 10 Mar 2014 19:48:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Originating-IP: [86.6.157.246] X-Spam: 0 X-Authority: v=2.1 cv=ef2zft0H c=1 sm=1 tr=0 a=BvYiZ/UW0Fmn8Wufq9dPrg==:117 a=BvYiZ/UW0Fmn8Wufq9dPrg==:17 a=NLZqzBF-AAAA:8 a=CGm-5s3DPqMA:10 a=uObrxnre4hsA:10 a=kj9zAlcOel0A:10 a=3CEjctkST1s7PRrxP_sA:9 a=CjuIK1q_8ugA:10 Date: Mon, 10 Mar 2014 19:42:39 +0000 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: return up two levels? Message-ID: <20140310194239.0a3bde92@pws-pc.ntlworld.com> In-Reply-To: <531E0393.6060106@eastlink.ca> References: <140310083224.ZM10646@torch.brasslantern.com> <531E0393.6060106@eastlink.ca> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 10 Mar 2014 11:25:23 -0700 Ray Andrews wrote: > Didn't I read somewhere that one can return from a function 'up two > levels'? i.e. that if function1 calls function2, that function2 can > return both itself and function1? function1() { function2; print Doesn\'t get called; } function2() { trap 'return' EXIT; print Does get called; } % function1 Does get called Of course you can return at the point you set the trap, I'm just illustrating that the forced return of the parent function isn't tied to the child function returning immediately. And regardless of options EXIT traps are only associated with the immediate parent, so... function0() { function1; print Does get called, too; } % function0 Does get called Does get called, too So forcing a whole hierarchy to return immediately is harder work. You can set an exit trap inside an exit trap, if you want (I haven't tried but I have a vague memory of debugging this years ago), but it gets messy. pws