From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20646 invoked by alias); 11 Mar 2014 14:54:33 -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: 18586 Received: (qmail 13906 invoked from network); 11 Mar 2014 14:54:26 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Authority-Analysis: v=2.1 cv=Xr3DZz19 c=1 sm=1 tr=0 a=C0g08kOJMvqFFjNsah5K5g==:117 a=C0g08kOJMvqFFjNsah5K5g==:17 a=HIA4oEAs-AEA:10 a=CGm-5s3DPqMA:10 a=IkcTkHD0fZMA:10 a=KGk5JxlzaZoqiGjZpQ8A:9 a=QEXdDO2ut3YA:10 Message-id: <531F23AE.5020404@eastlink.ca> Date: Tue, 11 Mar 2014 07:54:38 -0700 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: return up two levels? References: <140310083224.ZM10646@torch.brasslantern.com> <531E0393.6060106@eastlink.ca> <20140310194239.0a3bde92@pws-pc.ntlworld.com> <531E7C37.9070302@eastlink.ca> In-reply-to: Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 7bit On 03/10/2014 08:33 PM, Kurtis Rader wrote: > Please don't use that technique unless it's in the context of something > atypical like a debugger. It's a really bad software pattern. It's spooky > action at a distance. It's a form of monkey-patching. it practically > guarantees hard to debug errors. Plus a large number of other problems. > Don't do it. Be explicit about return values. If you want a caller of > function2 to exit immediately have function2 return non-zero and test for > that. For example, > > function2() { print I failed to do my job; return 1 } > function1() { if ! function2; then; print unexpected failure; return 0; fi; > print life is good } > Hmmm, sobering advice. I'm always looking to expand the techniques available to me, and Peter's 'trap' idea does/would streamline my code for this one particular problem, which is just a very short helper function called in almost all of my other functions in a trivial and routine sort of way where there are unlikely to be any strange issues. Still, this trap thing violates the rule of least surprise and breaks the basic rules of code flow, so I do take your point. I guess if this sort of thing can be considered 'standard zsh practice' then I'm inclined to keep it, but if not, then out it goes. But all the 'sh's' have so many abominable and dirty practices anyway that this trap would hardly stand out ;-)