From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10738 invoked by alias); 19 Feb 2010 12:21:21 -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: 27723 Received: (qmail 27329 invoked from network); 19 Feb 2010 12:21:01 -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.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.2.5 Received-SPF: none (ns2.melb.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Fri, 19 Feb 2010 12:14:54 +0000 From: Peter Stephenson To: zsh-workers@zsh.org (Zsh hackers list) Subject: Re: PATCH: minor condition fixes Message-ID: <20100219121454.697a7ae7@news01> In-Reply-To: <22045.1266580957@csr.com> References: <22045.1266580957@csr.com> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 19 Feb 2010 12:14:54.0212 (UTC) FILETIME=[24DE8C40:01CAB15D] X-Scanned-By: MailControl A-09-22-10 (www.mailcontrol.com) on 10.68.0.114 On Fri, 19 Feb 2010 12:02:37 +0000 Peter Stephenson wrote: > Then there's a problem I haven't fixed, which is for some reason in the > test code the status is returning as 1 for an unrecognised condition > whereas it should return 2 (and does at the command line). This shows > up with: > > % eval '[[ -fail badly ]]' > zsh: unknown condition: -fail > % print $? > 1 I think it's as simple as the following; certainly the documentation for "eval" says quite clearly it returns the same status as executing the code directly, and so does the principle of least surprise, so I don't see how the current behaviour can be right. One would hope that the "if" I've modified is redundant, in fact: the code already executed should have set lastval. However, it should now be harmless, I hope. This means fixing a glob test. It really is a fix; again, the status 2 was already returned if there was no eval, and that's what we should be testing. (Of course if you tell me the pattern code should really return status 1 that's a different bug, but I think it's correct with the patch.) I'll modify the other patch accordingly. Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.239 diff -p -u -r1.239 builtin.c --- Src/builtin.c 7 Feb 2010 18:49:36 -0000 1.239 +++ Src/builtin.c 19 Feb 2010 12:06:16 -0000 @@ -4885,7 +4885,7 @@ eval(char **argv) } else { execode(prog, 1, 0); - if (errflag) + if (errflag && !lastval) lastval = errflag; } } else { Index: Test/D02glob.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/D02glob.ztst,v retrieving revision 1.16 diff -p -u -r1.16 D02glob.ztst --- Test/D02glob.ztst 9 Feb 2010 17:47:04 -0000 1.16 +++ Test/D02glob.ztst 19 Feb 2010 12:06:16 -0000 @@ -425,7 +425,7 @@ >/ [[:WORD:]] yes [[ foo = (#c0)foo ]] -1:Misplaced (#c...) flag +2:Misplaced (#c...) flag ?(eval):1: bad pattern: (#c0)foo mkdir glob.tmp/dir5 -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom