about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-04-01 10:16:59 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-04-01 10:16:59 +0000
commitb51472dd5fda1d4a0e8273d675da03dcbb37c8d6 (patch)
tree269bed9e207c6d94e5d5496dd1ba1c0ab8da0100
parent835a5ad8b506af216a52a606243c8f73654f1a83 (diff)
downloadzsh-b51472dd5fda1d4a0e8273d675da03dcbb37c8d6.tar.gz
zsh-b51472dd5fda1d4a0e8273d675da03dcbb37c8d6.tar.xz
zsh-b51472dd5fda1d4a0e8273d675da03dcbb37c8d6.zip
21078: parse errors didn't cause non-zero exit status
-rw-r--r--ChangeLog5
-rw-r--r--Src/init.c5
-rw-r--r--Test/A01grammar.ztst9
3 files changed, 19 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 6fd8075cc..75a78570c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-04-01  Peter Stephenson  <pws@csr.com>
+
+	* 21078: Src/init.c, Test/A01grammar.ztst: parse errors didn't
+	cause non-zero exit status.
+
 2005-03-31  Oliver Kiddle  <opk@zsh.org>
 
 	* 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 <unmatched_quote.txt
+1:Parse error on standard input causes non-zero exit status
+?zsh: unmatched '