From: Dan Nelson <dnelson@allantgroup.com>
To: zsh-workers@sunsite.dk
Subject: Re: Parse errors don't cause a non-zero exit code?
Date: Thu, 31 Mar 2005 11:14:21 -0600 [thread overview]
Message-ID: <20050331171421.GG46288@dan.emsphone.com> (raw)
In-Reply-To: <20050329231719.GH51674@dan.emsphone.com>
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@allantgroup.com
next prev parent reply other threads:[~2005-03-31 17:14 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 [this message]
2005-04-01 10:07 ` Peter Stephenson
2005-04-01 20:06 ` Dan Nelson
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=20050331171421.GG46288@dan.emsphone.com \
--to=dnelson@allantgroup.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).