Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] Redirect between two parameter assignments causes misbehaviour



On Sun, 10 Dec 2017 18:19:18 -0600
dana <dana@xxxxxxx> wrote:
> The following command produces no output (and returns with 0):
> 
>   % a=b 2> /dev/null c=d env

This is certainly documented to work.

As redirections at the start work OK I think the fix is as simple as
this.

diff --git a/Src/parse.c b/Src/parse.c
index 5fe3ebd..6af2550 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -1848,6 +1848,10 @@ par_simple(int *cmplx, int nr)
 	    incmdpos = oldcmdpos;
 	    isnull = 0;
 	    assignments = 1;
+	} else if (IS_REDIROP(tok)) {
+	    *cmplx = c = 1;
+	    nr += par_redir(&r, NULL);
+	    continue;
 	} else
 	    break;
 	zshlex();
diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst
index cb82751..b8105cf 100644
--- a/Test/A04redirect.ztst
+++ b/Test/A04redirect.ztst
@@ -622,3 +622,10 @@
 >FOO
 >HERE
 >}
+
+  a=b 2>/dev/null c=d
+  print $a
+  print $c
+0:Redirect in the middle of assignments
+>b
+>d



Messages sorted by: Reverse Date, Date, Thread, Author