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 21077
- From: Dan Nelson <dnelson@xxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: Parse errors don't cause a non-zero exit code?
- Date: Thu, 31 Mar 2005 11:14:21 -0600
- In-reply-to: <20050329231719.GH51674@xxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20050329231719.GH51674@xxxxxxxxxxxxxxxx>
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:
--- Src/init.c~ Thu Mar 31 00:49:30 2005
+++ Src/init.c Thu Mar 31 00:49:30 2005
@@ -983,6 +983,8 @@ init_misc(void)
bshin = fdopen(SHIN, "r");
execstring(cmd, 0, 1);
stopmsg = 1;
+ if (errflag)
+ lastval = errflag;
zexit(lastval, 0);
}
@@ -1277,6 +1277,8 @@ zsh_main(UNUSED(int argc), char **argv)
while (tok != ENDINPUT && (tok != LEXERR || isset(SHINSTDIN)));
if (tok == LEXERR) {
stopmsg = 1;
+ if (errflag)
+ lastval = errflag;
zexit(lastval, 0);
}
if (!(isset(IGNOREEOF) && interact)) {
--- Src/lex.c~ Thu Mar 31 00:58:03 2005
+++ Src/lex.c Thu Mar 31 00:58:03 2005
@@ -330,7 +330,6 @@ lexrestore(void)
ecssub = lstack->ecssub;
ecnfunc = lstack->ecnfunc;
hlinesz = lstack->hlinesz;
- errflag = 0;
ln = lstack->next;
free(lstack);
--
Dan Nelson
dnelson@xxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author