From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8783 invoked by alias); 5 Nov 2012 14:55:07 -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: 30779 Received: (qmail 21346 invoked from network); 5 Nov 2012 14:55:06 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at samsung.com does not designate permitted sender hosts) Date: Mon, 05 Nov 2012 14:55:01 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Function code breaking out of if then ...fi Message-id: <20121105145501.50c674f1@pwslap01u.europe.root.pri> In-reply-to: <20121105142942.41d73d31@pwslap01u.europe.root.pri> References: <121102143911.ZM14168@torch.brasslantern.com> <20121105142942.41d73d31@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-TM-AS-MML: No On Mon, 05 Nov 2012 14:29:42 +0000 Peter Stephenson wrote: > It's not really like a break, it's like (well, is) a global error flag > --- but the error status gets reset at the top level command loop, > which we reach in a script after the end of a set of complex commands > --- but only right at the end, when we're reading a new (possibly > complex, arbitrarily nested) command from the script. > > I think actually what's going on could be considered a bug which is an > oversight for the case of scripts. Hmmm... there are multiple loops here and they have different error handling. In loop(), if (((!interact || sourcelevel) && errflag) || retflag) break; This actually does what I want: if it's not interactive, and there's an error, break out of the loop. This is the "top level" loop I was thinking of. However, there are two even topper level loops in zsh_main(). They appear to be limited to handling the case of hitting EOF and a parse error --- no other sort of error --- however, and aren't restricted to interactive behaviour. I don't really like the look of the combination of these three loops --- it smells to me like the effect hasn't been thought through properly. I can see you need to exit if you've got a parse error, because you don't know what to execute yet, but I don't see that you need to ignore all other errors in the outer loops. retflag and sourcelevel are irrelevant out here but I can definitely see a case for "if (!interact && errflag) /* exit */". pws