summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--Src/exec.c7
-rw-r--r--Test/A04redirect.ztst7
3 files changed, 18 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ab6fd63e..5c25e3bc8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-06  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 28866: Src/exec.c, Test/A04redirect.ztst: With POSIX_BUILTINS,
+	"command" prefix tops a command having special behaviour.
+
 2011-03-05  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* Adrian: 28857: Functions/Prompts/prompt_bigfade_setup: use %d
@@ -14297,5 +14302,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5215 $
+* $Revision: 1.5216 $
 *****************************************************
diff --git a/Src/exec.c b/Src/exec.c
index f1b87e152..9c72c68af 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2324,7 +2324,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
     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. */
-    int cflags = 0, checked = 0, oautocont = -1;
+    int cflags = 0, orig_cflags = 0, checked = 0, oautocont = -1;
     LinkList redir;
     wordcode code;
     Wordcode beg = state->pc, varspc;
@@ -2416,6 +2416,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		checked = !(cflags & BINF_BUILTIN);
 		break;
 	    }
+	    orig_cflags |= cflags;
 	    cflags &= ~BINF_BUILTIN & ~BINF_COMMAND;
 	    cflags |= hn->flags;
 	    if (!(hn->flags & BINF_PREFIX)) {
@@ -3298,11 +3299,13 @@ execcmd(Estate state, int input, int output, int how, int last1)
 
  done:
     if (isset(POSIXBUILTINS) &&
-	(cflags & (BINF_PSPECIAL|BINF_EXEC))) {
+	(cflags & (BINF_PSPECIAL|BINF_EXEC)) &&
+	!(orig_cflags & BINF_COMMAND)) {
 	/*
 	 * For POSIX-compatible behaviour with special
 	 * builtins (including exec which we don't usually
 	 * classify as a builtin) we treat all errors as fatal.
+	 * The "command" builtin is not special so resets this behaviour.
 	 */
 	if (redir_err || errflag) {
 	    if (!isset(INTERACTIVE)) {
diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst
index 9340b71f0..4d96d8bb9 100644
--- a/Test/A04redirect.ztst
+++ b/Test/A04redirect.ztst
@@ -386,6 +386,13 @@
 ?zsh:2: no such file or directory: /nonexistent/nonexistent
 
   $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
+  command set >/nonexistent/nonexistent
+  echo output'
+0:failed special builtin redir with command prefix, POSIX_BUILTINS
+>output
+?zsh:2: no such file or directory: /nonexistent/nonexistent
+
+  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
   echo >/nonexistent/nonexistent
   echo output'
 0:failed unspecial builtin redir, POSIX_BUILTINS