Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Anonymous function with redirection and arguments
- X-seq: zsh-users 22688
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Anonymous function with redirection and arguments
- Date: Mon, 08 May 2017 17:07:27 +0100
- Cms-type: 201P
- In-reply-to: <20170508024741.GA19237@fujitsu.shahaf.local2>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <CGME20170508024902epcas3p1e81421caa823e3c28d8a333b935cd5c5@epcas3p1.samsung.com> <20170508024741.GA19237@fujitsu.shahaf.local2>
On Mon, 8 May 2017 02:47:41 +0000
Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> $ zsh -f
> % () { echo foo $1 } >1; cat 1; rm -f 1
> foo
> % () { echo foo $1 } bar >1; cat 1; rm -f 1
> foo bar
> % () { echo foo $1 } >1 bar; cat 1; rm -f 1
> zsh: parse error near `bar'
> %
>
> It shouldn't parse error, should it?
There's no obvious reason why they shouldn't be mixed.
pws
diff --git a/Src/parse.c b/Src/parse.c
index 83e87af..b0de9a8 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 a5de552..2671080 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
+ } <input1 Shirley >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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author