From b51472dd5fda1d4a0e8273d675da03dcbb37c8d6 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 1 Apr 2005 10:16:59 +0000 Subject: 21078: parse errors didn't cause non-zero exit status --- ChangeLog | 5 +++++ Src/init.c | 5 +++++ Test/A01grammar.ztst | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6fd8075cc..75a78570c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-04-01 Peter Stephenson + + * 21078: Src/init.c, Test/A01grammar.ztst: parse errors didn't + cause non-zero exit status. + 2005-03-31 Oliver Kiddle * 21076: Completion/Unix/Command/_subversion: use _files with diff --git a/Src/init.c b/Src/init.c index 903df47cd..1ad9559f0 100644 --- a/Src/init.c +++ b/Src/init.c @@ -131,6 +131,8 @@ loop(int toplevel, int justonce) (tok == LEXERR && (!isset(SHINSTDIN) || !toplevel)) || justonce) break; + if (tok == LEXERR && !lastval) + lastval = 1; continue; } if (hend(prog)) { @@ -1282,6 +1284,9 @@ zsh_main(UNUSED(int argc), char **argv) 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); } diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst index a856b8ccc..81a963b05 100644 --- a/Test/A01grammar.ztst +++ b/Test/A01grammar.ztst @@ -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