From 641a764b8203de5e5f5c9f1d6d5b0a48c26ca9e7 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 8 May 2017 17:19:22 +0100 Subject: users/22688: Allow mixing redirs and arguments after anon functions. These are parsed differently from the case of normal functions which can't take normal arguments at that point. --- ChangeLog | 3 +++ Src/parse.c | 19 +++++++++++++++---- Test/A04redirect.ztst | 12 ++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 112a53d1a..8ac6df15e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2017-05-08 Peter Stephenson + * users/22688: Src/parse.c, Test/A04redirect.ztst: Allow mixing + of redirections and arguments after anonymous functions. + * 41060: Src/parse.c, Test/A04redirect.ztst: combination of HERE document and |& was broken by miscounting wordcode owing to missing flag. diff --git a/Src/parse.c b/Src/parse.c index 83e87afed..b0de9a863 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -2030,10 +2030,21 @@ par_simple(int *cmplx, int nr) /* Unnamed function */ int parg = ecadd(0); ecadd(0); - while (tok == STRING) { - ecstr(tokstr); - argc++; - zshlex(); + while (tok == STRING || IS_REDIROP(tok)) { + if (tok == STRING) + { + ecstr(tokstr); + argc++; + zshlex(); + } else { + *cmplx = c = 1; + nrediradd = par_redir(&r, NULL); + p += nrediradd; + if (ppost) + ppost += nrediradd; + sr += nrediradd; + parg += nrediradd; + } } if (argc > 0) *cmplx = 1; diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst index a5de552c1..2671080c2 100644 --- a/Test/A04redirect.ztst +++ b/Test/A04redirect.ztst @@ -475,6 +475,18 @@ >Nothing output yet >I just read any old rubbish + print you cannot be serious >input1 + () { + local var + read var + print $1 $var $2 + } output1 dude + print Nothing output yet + cat output1 +0:anonymous function redirections mixed with argument +>Nothing output yet +>Shirley you cannot be serious dude + redirfn() { local var read var -- cgit 1.4.1