From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14883 invoked from network); 1 Apr 2005 10:07:46 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 1 Apr 2005 10:07:46 -0000 Received: (qmail 89945 invoked from network); 1 Apr 2005 10:07:41 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 1 Apr 2005 10:07:41 -0000 Received: (qmail 3103 invoked by alias); 1 Apr 2005 10:07:35 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21078 Received: (qmail 3081 invoked from network); 1 Apr 2005 10:07:33 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 1 Apr 2005 10:07:33 -0000 Received: (qmail 89530 invoked from network); 1 Apr 2005 10:07:33 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 1 Apr 2005 10:07:24 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Fri, 1 Apr 2005 11:05:47 +0100 Received: from news01.csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 1 Apr 2005 11:09:52 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.1/8.12.11) with ESMTP id j31A7NH0029293 for ; Fri, 1 Apr 2005 11:07:23 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.13.1/8.13.1/Submit) with ESMTP id j31A7MU2029290 for ; Fri, 1 Apr 2005 11:07:22 +0100 Message-Id: <200504011007.j31A7MU2029290@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk Subject: Re: Parse errors don't cause a non-zero exit code? In-reply-to: <20050331171421.GG46288@dan.emsphone.com> References: <20050329231719.GH51674@dan.emsphone.com> <20050331171421.GG46288@dan.emsphone.com> Date: Fri, 01 Apr 2005 11:07:22 +0100 From: Peter Stephenson X-OriginalArrivalTime: 01 Apr 2005 10:09:52.0350 (UTC) FILETIME=[F20D7FE0:01C536A2] X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 Dan Nelson wrote: > In the last episode (Mar 29), Dan Nelson said: > > $ echo "'" > /tmp/test ; zsh -f /tmp/test ; echo $? > > /tmp/test:2: unmatched ' > > 0 > > > > ksh93, ash, and bash all return non-zero here, and it looks like > > http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag > _02_08 > > wants a non-zero result also. > > I'm thinking something like this, but I don't know enough about zsh > internals to say that propagating errflag into lastval here is the > right fix. It doesn't break the testsuite at least: I came up with this. It uses the LEXERR to signal the error rather than propagating errflag. I found there was another case which still didn't return non-zero status, when the same code came from stdin. That needed handling at the next level down. I've added tests for both. Index: Src/init.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/init.c,v retrieving revision 1.49 diff -u -r1.49 init.c --- Src/init.c 31 Mar 2005 09:54:59 -0000 1.49 +++ Src/init.c 1 Apr 2005 10:02:41 -0000 @@ -131,6 +131,8 @@ (tok == LEXERR && (!isset(SHINSTDIN) || !toplevel)) || justonce) break; + if (tok == LEXERR && !lastval) + lastval = 1; continue; } if (hend(prog)) { @@ -1282,6 +1284,9 @@ loop(1,0); while (tok != ENDINPUT && (tok != LEXERR || isset(SHINSTDIN))); if (tok == LEXERR) { + /* Make sure a parse error exits with non-zero status */ + if (!lastval) + lastval = 1; stopmsg = 1; zexit(lastval, 0); } Index: Test/A01grammar.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v retrieving revision 1.9 diff -u -r1.9 A01grammar.ztst --- Test/A01grammar.ztst 22 Jun 2004 13:10:02 -0000 1.9 +++ Test/A01grammar.ztst 1 Apr 2005 10:02:41 -0000 @@ -7,6 +7,7 @@ mkdir basic.tmp && cd basic.tmp touch foo bar + echo "'" >unmatched_quote.txt %test # @@ -439,3 +440,11 @@ done || print no 0:Handling of &&'s and ||'s with a for loop in between >no + + $ZTST_testdir/../Src/zsh -f unmatched_quote.txt +1:Parse error with file causes non-zero exit status +?unmatched_quote.txt:2: unmatched ' + + $ZTST_testdir/../Src/zsh -f Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. **********************************************************************