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-21 11:28:49 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2011-02-21 11:28:49 +0000
commit0e792b944707fdb8abafa4b4e3f3952154189c6f (patch)
tree0730059b6994adb39e85e65f6eb282310164e2d1 /Src/exec.c
parent3c020a9a9c3b0cee6c25e565e001e3bbc0e1c421 (diff)
downloadzsh-0e792b944707fdb8abafa4b4e3f3952154189c6f.tar.gz
zsh-0e792b944707fdb8abafa4b4e3f3952154189c6f.tar.xz
zsh-0e792b944707fdb8abafa4b4e3f3952154189c6f.zip
28784: exit on exec redirection error with POISX_BUILTINS
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 11d37f1b3..da67465d8 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -181,7 +181,15 @@ struct execstack *exstack;
 /**/
 mod_export Funcstack funcstack;
 
-#define execerr() if (!forked) { lastval = 1; goto done; } else _exit(1)
+#define execerr()				\
+    do {					\
+	if (!forked) {				\
+	    redir_err = lastval = 1;		\
+	    goto done;				\
+	} else {				\
+	    _exit(1);				\
+	}					\
+    } while (0)
 
 static int doneps4;
 static char *STTYval;
@@ -2312,7 +2320,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
     struct multio *mfds[10];
     char *text;
     int save[10];
-    int fil, dfil, is_cursh, type, do_exec = 0, i, htok = 0;
+    int fil, dfil, is_cursh, type, do_exec = 0, redir_err = 0, i, htok = 0;
     int nullexec = 0, assign = 0, forked = 0;
     int is_shfunc = 0, is_builtin = 0, is_exec = 0, use_defpath = 0;
     /* Various flags to the command. */
@@ -3289,6 +3297,13 @@ 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);
+	}
+	errflag = 1;
+    }
     if (newxtrerr) {
 	fil = fileno(newxtrerr);
 	fclose(newxtrerr);