From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 337 invoked by alias); 25 Nov 2014 08:00:55 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33791 Received: (qmail 9466 invoked from network); 25 Nov 2014 08:00:54 -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-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=IOK10brD c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=5y4faFyK3SkA:10 a=u6V6tg94bStULnSKYeEA:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <141125000123.ZM17533@torch.brasslantern.com> Date: Tue, 25 Nov 2014 00:01:23 -0800 In-reply-to: <20141124101152.39741cc8@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: TRY_BLOCK_ERROR and exit status" (Nov 24, 10:11am) References: <5470C427.4050805@thequod.de> <5470CF7C.2000707@thequod.de> <5472040F.8020803@thequod.de> <141123115755.ZM10874@torch.brasslantern.com> <20141124101152.39741cc8@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh workers Subject: Re: TRY_BLOCK_ERROR and exit status MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Nov 24, 10:11am, Peter Stephenson wrote: } } > other hand I think always+TRY_BLOCK_ERROR is the only way lastval can } > still be examined after errflag has been set, so maybe it would suffice } > to handle this there? } } Yes, probably. } } > What should the value of lastval ($?) be in this circumstance? } } The easiest way out is probably to leave it if it's non-zero, else set } it to 1. } } Given that "always" isn't all that widely used, changing it to return } the last status of the always block might also work. However, it } doesn't look necessary to go that far. Do you mean return the last status of the always block only in the case where errflag is nonzero at the end of the try block? If that's not what you mean, wouldn't that break the current normal use case where always is for cleaning up whether or not there was an error? I agree it isn't necessary to go that far. This? diff --git a/Src/loop.c b/Src/loop.c index 2f639fd..82d2fe3 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -659,8 +659,9 @@ exectry(Estate state, int do_exec) try_tryflag = save_try_tryflag; - /* Don't record errflag here, may be reset. */ - endval = lastval; + /* Don't record errflag here, may be reset. However, */ + /* endval should show failure when there is an error. */ + endval = lastval ? lastval : errflag; freeheap();