From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5609 invoked from network); 6 Jul 2009 20:48:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) 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.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 6 Jul 2009 20:48:21 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 81050 invoked from network); 6 Jul 2009 20:40:13 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 6 Jul 2009 20:40:13 -0000 Received: (qmail 10613 invoked by alias); 6 Jul 2009 20:39:59 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27092 Received: (qmail 10593 invoked from network); 6 Jul 2009 20:39:58 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 6 Jul 2009 20:39:58 -0000 Received: from mtaout01-winn.ispmail.ntl.com (mtaout01-winn.ispmail.ntl.com [81.103.221.47]) by bifrost.dotsrc.org (Postfix) with ESMTP id 290FA8027106 for ; Mon, 6 Jul 2009 22:39:54 +0200 (CEST) Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20090706203954.OZWT6742.mtaout01-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com> for ; Mon, 6 Jul 2009 21:39:54 +0100 Received: from pws-pc ([81.107.42.185]) by aamtaout03-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20090706203953.XJA2093.aamtaout03-winn.ispmail.ntl.com@pws-pc> for ; Mon, 6 Jul 2009 21:39:53 +0100 Date: Mon, 6 Jul 2009 21:39:49 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: zsh bug in . builtin Message-ID: <20090706213949.15f30194@pws-pc> In-Reply-To: References: <4A4B614E.7000406@byu.net> <20090701152420.2beb1c78@news01> X-Mailer: Claws Mail 3.7.1 (GTK+ 2.16.2; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.0 c=1 a=9vXuR5GGAAAA:8 a=NLZqzBF-AAAA:8 a=rDYhkijIvqSw1lNnLqkA:9 a=St2OTuA6KjpngChFOWMA:7 a=pU1Fvlfqldk3AkrtH7dDZHboLmsA:4 a=eDFNAWYWrCwA:10 a=_dQi-Dcv4p4A:10 X-Virus-Scanned: ClamAV 0.94.2/9538/Fri Jul 3 16:27:11 2009 on bifrost X-Virus-Status: Clean On Thu, 2 Jul 2009 12:01:11 +0000 (UTC) Eric Blake wrote: > Also, you may want to consistently detect syntax errors in eval and in the > action to trap: > > $ zsh -c 'eval "if"; echo $?' > 0 The problem isn't in eval or trap. The problem is that the short form of "if" (which is an abomination anyway and no one should use) isn't tested properly. Adding the test below to the parser should fix it. My heart sank when this caused a failure in the test system---however, having read the manual again, that test should never have worked, since the if-clause wasn't delimited, which is the prerequisite for the syntax to work. The old if-clause therefore extended to the end of the evaluated block and the then-clause was missing, so failing is correct. (If you're not convinced, try eval'ing "if false; print False is true" and you'll see it gets to the "print", because it's still looking for the end of the if-clause at that point.) I've fixed the tests. Index: Src/parse.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/parse.c,v retrieving revision 1.79 diff -u -r1.79 parse.c --- Src/parse.c 25 Feb 2009 10:24:01 -0000 1.79 +++ Src/parse.c 6 Jul 2009 20:28:56 -0000 @@ -1199,6 +1199,10 @@ type = (xtok == IF ? WC_IF_IF : WC_IF_ELIF); par_save_list(complex); incmdpos = 1; + if (tok == ENDINPUT) { + cmdpop(); + YYERRORV(oecused); + } while (tok == SEPER) zshlex(); xtok = FI; Index: Test/A01grammar.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v retrieving revision 1.21 diff -u -r1.21 A01grammar.ztst --- Test/A01grammar.ztst 2 Jul 2009 13:48:36 -0000 1.21 +++ Test/A01grammar.ztst 6 Jul 2009 20:28:56 -0000 @@ -378,10 +378,15 @@ >true-2 >false - if true; print true + if { true } print true + if { false } print false 0:Short form of `if' >true + eval "if" +1:Short form of `if' can't be too short +?(eval):1: parse error near `if' + for name ( word1 word2 word3 ) print $name 0:Form of `for' with parentheses. >word1 -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/