about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2011-02-22 20:09:20 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2011-02-22 20:09:20 +0000
commitdbbcbf67cb8a330e5c7d8a40ed4152a53db6b5f8 (patch)
tree41ec7fbda389e5ec8d04a8c3ad21b27f01659912 /Src/exec.c
parent73ebca4fe92767665422e7fd5dc15032add389b4 (diff)
downloadzsh-dbbcbf67cb8a330e5c7d8a40ed4152a53db6b5f8.tar.gz
zsh-dbbcbf67cb8a330e5c7d8a40ed4152a53db6b5f8.tar.xz
zsh-dbbcbf67cb8a330e5c7d8a40ed4152a53db6b5f8.zip
28791: exit on errors with special builtins with POSIXBUILTINS
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/Src/exec.c b/Src/exec.c
index da67465d8..25a2eee38 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2416,6 +2416,8 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		checked = !(cflags & BINF_BUILTIN);
 		break;
 	    }
+	    cflags &= ~BINF_BUILTIN & ~BINF_COMMAND;
+	    cflags |= hn->flags;
 	    if (!(hn->flags & BINF_PREFIX)) {
 		is_builtin = 1;
 
@@ -2425,8 +2427,6 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		assign = (hn->flags & BINF_MAGICEQUALS);
 		break;
 	    }
-	    cflags &= ~BINF_BUILTIN & ~BINF_COMMAND;
-	    cflags |= hn->flags;
 	    checked = 0;
 	    if ((cflags & BINF_COMMAND) && nextnode(firstnode(args))) {
 		/* check for options to command builtin */
@@ -3297,12 +3297,20 @@ execcmd(Estate state, int input, int output, int how, int last1)
     fixfds(save);
 
  done:
-    if (redir_err && isset(POSIXBUILTINS)) {
-	if (!isset(INTERACTIVE)) {
-	    /* We've already _exit'ed if forked */
-	    exit(1);
+    if (isset(POSIXBUILTINS) &&
+	(cflags & (BINF_PSPECIAL|BINF_EXEC))) {
+	/*
+	 * For POSIX-compatibile behaviour with special
+	 * builtins (including exec which we don't usually
+	 * classify as a builtin, we treat all errors as fatal.
+	 */
+	if (redir_err || errflag) {
+	    if (!isset(INTERACTIVE)) {
+		/* We've already _exit'ed if forked */
+		exit(1);
+	    }
+	    errflag = 1;
 	}
-	errflag = 1;
     }
     if (newxtrerr) {
 	fil = fileno(newxtrerr);