Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Parse errors don't cause a non-zero exit code?
- X-seq: zsh-workers 21082
- From: Dan Nelson <dnelson@xxxxxxxxxxxxxxx>
- To: Peter Stephenson <pws@xxxxxxx>
- Subject: Re: Parse errors don't cause a non-zero exit code?
- Date: Fri, 1 Apr 2005 14:06:42 -0600
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <200504011007.j31A7MU2029290@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20050329231719.GH51674@xxxxxxxxxxxxxxxx> <20050331171421.GG46288@xxxxxxxxxxxxxxxx> <200504011007.j31A7MU2029290@xxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author