zsh-workers
 help / color / mirror / code / Atom feed
From: Dan Nelson <dnelson@allantgroup.com>
To: Peter Stephenson <pws@csr.com>
Cc: zsh-workers@sunsite.dk
Subject: Re: Parse errors don't cause a non-zero exit code?
Date: Fri, 1 Apr 2005 14:06:42 -0600	[thread overview]
Message-ID: <20050401200642.GC4564@dan.emsphone.com> (raw)
In-Reply-To: <200504011007.j31A7MU2029290@news01.csr.com>

In the last episode (Apr 01), Peter Stephenson said:
> 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
> 
> 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.

There's a third case: input passed via -c.  Possible fix and testcase. 

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.85
diff -u -p -r1.85 exec.c
--- Src/exec.c	31 Mar 2005 09:54:59 -0000	1.85
+++ Src/exec.c	1 Apr 2005 19:56:59 -0000
@@ -162,6 +162,8 @@ parse_string(char *s)
     lineno = 1;
     p = parse_list();
     lineno = oldlineno;
+    if (tok == LEXERR && !lastval)
+	lastval = 1;
     strinend();
     inpop();
     lexrestore();
Index: Test/A01grammar.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v
retrieving revision 1.10
diff -u -p -r1.10 A01grammar.ztst
--- Test/A01grammar.ztst	1 Apr 2005 10:17:25 -0000	1.10
+++ Test/A01grammar.ztst	1 Apr 2005 19:56:59 -0000
@@ -448,3 +448,7 @@
   $ZTST_testdir/../Src/zsh -f <unmatched_quote.txt
 1:Parse error on standard input causes non-zero exit status
 ?zsh: unmatched '
+
+  $ZTST_testdir/../Src/zsh -f -c "'"
+1:Parse error on inline command causes non-zero exit status
+?zsh: unmatched '


-- 
	Dan Nelson
	dnelson@allantgroup.com


  reply	other threads:[~2005-04-01 20:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-29 23:17 Dan Nelson
2005-03-31 17:14 ` Dan Nelson
2005-04-01 10:07   ` Peter Stephenson
2005-04-01 20:06     ` Dan Nelson [this message]
2005-04-01 12:08 ` Peter Stephenson
2005-04-09  0:50   ` Felipe Kellermann
2005-04-11 10:13     ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050401200642.GC4564@dan.emsphone.com \
    --to=dnelson@allantgroup.com \
    --cc=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).