From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11970 invoked from network); 4 Oct 2005 17:45:46 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 4 Oct 2005 17:45:46 -0000 Received: (qmail 79571 invoked from network); 4 Oct 2005 17:45:40 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Oct 2005 17:45:40 -0000 Received: (qmail 14105 invoked by alias); 4 Oct 2005 17:45:38 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21839 Received: (qmail 14093 invoked from network); 4 Oct 2005 17:45:37 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 4 Oct 2005 17:45:37 -0000 Received: (qmail 79286 invoked from network); 4 Oct 2005 17:45:37 -0000 Received: from ns9.hostinglmi.net (213.194.149.146) by a.mx.sunsite.dk with SMTP; 4 Oct 2005 17:45:36 -0000 Received: from 212.red-80-35-44.staticip.rima-tde.net ([80.35.44.212] helo=localhost) by ns9.hostinglmi.net with esmtpa (Exim 4.52) id 1EMqrB-0002wg-DB; Tue, 04 Oct 2005 19:45:37 +0200 Date: Tue, 4 Oct 2005 19:46:04 +0200 From: DervishD To: Peter Stephenson Cc: zsh-workers@sunsite.dk Subject: Re: Exception handling and "trap" vs. TRAPNAL() Message-ID: <20051004174604.GA21210@DervishD> Mail-Followup-To: Peter Stephenson , zsh-workers@sunsite.dk References: <20051002190940.437F9866F@pwstephenson.fsnet.co.uk> <1051002195518.ZM2163@candle.brasslantern.com> <20051002230027.GA194@DervishD> <1051003013758.ZM3107@candle.brasslantern.com> <20051003090121.GC278@DervishD> <1051003162109.ZM4533@candle.brasslantern.com> <20051003175913.GB3231@DervishD> <1051004163144.ZM32294@candle.brasslantern.com> <20051004172910.GA21195@DervishD> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.1i Organization: DervishD X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - ns9.hostinglmi.net X-AntiAbuse: Original Domain - sunsite.dk X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - dervishd.net X-Source: X-Source-Args: X-Source-Dir: X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.4 Hi Peter :) * Peter Stephenson dixit: > DervishD wrote: > > Just one note: why should be always blocks needed at all if you > > can use this kind of solutions? As long as you don't cause ZERR to be > > raised in "common_error()", this solution is much better because you > > can fine tune (using the "trap" builtin) when do you want to do > > common handling and when you don't. The only difference I can see is > > that code in an always block is executed in the current environment > > and code in "common_error()" is not. > TRAP_RETURN triggers on any non-zero status, while an "always" block > is used to stop actual errors which would usually cause everything in > sight(*) to abort. If you're really concerned only with non-zero status > and don't care about errors there's every reason to go with something > like TRAP_RETURN. But you can check for those kind of errors like this: ( #whatever would have caused an abortive-error ) OK, you must run them in a subshell, but the fact is that this is doable. But I see, an always block here is far more readable and easy to use (apart from being more optimal if the 'abortive-error' can happen in a loop). OTOH, code like this is very annoying when trapping ZERR: # If the file doesn't exist, this will raise ZERR # We probably will want ZERR raised if "do_something" fails, # but certainly not if the test fails. We must use "if"... [[ -r "$filename" ]] && do_something Thanks for the explanation :) Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 | http://www.dervishd.net http://www.pleyades.net & http://www.gotesdelluna.net It's my PC and I'll cry if I want to...