about summary refs log tree commit diff
path: root/Src/init.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2012-11-15 21:08:15 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2012-11-15 21:08:15 +0000
commit7c56d771840a9f335b2e21290c8cbf714264bc66 (patch)
tree98907f1a578f3f13446d1ba91239088172807f01 /Src/init.c
parent1446625072033fe1c53af7324a9245ef9cdcfad2 (diff)
downloadzsh-7c56d771840a9f335b2e21290c8cbf714264bc66.tar.gz
zsh-7c56d771840a9f335b2e21290c8cbf714264bc66.tar.xz
zsh-7c56d771840a9f335b2e21290c8cbf714264bc66.zip
30789: Add CONTINUE_ON_ERROR for old behaviour.
New behaviour is for scripts to exit on error instead of returning
to top level and executing the next command.
Diffstat (limited to 'Src/init.c')
-rw-r--r--Src/init.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Src/init.c b/Src/init.c
index 6c2ba13e4..8467a739c 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1608,15 +1608,20 @@ zsh_main(UNUSED(int argc), char **argv)
 	 * We only do this at top level, because if we are
 	 * executing stuff we may refer to them by job pointer.
 	 */
+	int errexit = 0;
 	maybeshrinkjobtab();
 
 	do {
 	    /* Reset return from top level which gets us back here */
 	    retflag = 0;
 	    loop(1,0);
+	    if (errflag && !interact && !isset(CONTINUEONERROR)) {
+		errexit = 1;
+		break;
+	    }
 	} while (tok != ENDINPUT && (tok != LEXERR || isset(SHINSTDIN)));
-	if (tok == LEXERR) {
-	    /* Make sure a parse error exits with non-zero status */
+	if (tok == LEXERR || errexit) {
+	    /* Make sure a fatal error exits with non-zero status */
 	    if (!lastval)
 		lastval = 1;
 	    stopmsg = 1;