From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2401 invoked by alias); 27 Jul 2011 19:23:03 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29626 Received: (qmail 21157 invoked from network); 27 Jul 2011 19:22:49 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: neutral (ns1.primenet.com.au: 74.125.82.43 is neither permitted nor denied by SPF record at ntlworld.com) X-ProxyUser-IP: 86.27.188.118 Date: Wed, 27 Jul 2011 20:22:38 +0100 From: Peter Stephenson To: zsh workers Subject: Re: syntax error with anonymous functions when an argument begins with ( Message-ID: <20110727202238.37c469d0@pws-pc.ntlworld.com> In-Reply-To: References: X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.4; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit I think the fact the shell parses the token immediately after the "}" as a command word is an accident; for a real command to follow, we'd need a separator, just as with the end of a simple command line. Anyway, resetting the flags seems to work. Index: Src/parse.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/parse.c,v retrieving revision 1.88 diff -p -u -r1.88 parse.c --- Src/parse.c 19 Jun 2011 20:12:00 -0000 1.88 +++ Src/parse.c 27 Jul 2011 18:30:44 -0000 @@ -1465,6 +1465,7 @@ par_funcdef(void) ecssub = oecssub; YYERRORV(oecused); } + incmdpos = 0; zshlex(); } else if (unset(SHORTLOOPS)) { lineno += oldlineno; @@ -1720,6 +1721,7 @@ par_simple(int *complex, int nr) ecssub = oecssub; YYERROR(oecused); } + incmdpos = 0; zshlex(); } else { int ll, sl, c = 0; Index: Test/C04funcdef.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/C04funcdef.ztst,v retrieving revision 1.8 diff -p -u -r1.8 C04funcdef.ztst --- Test/C04funcdef.ztst 19 Jun 2011 20:12:00 -0000 1.8 +++ Test/C04funcdef.ztst 27 Jul 2011 18:30:44 -0000 @@ -1,3 +1,8 @@ +%prep + + mkdir funcdef.tmp + cd funcdef.tmp + %test fn1() { return 1; } @@ -228,6 +233,18 @@ > print Following bit >} + touch yes no + () { echo $1 } (y|z)* + (echo here) + () { echo $* } some (y|z)* + () { echo empty };(echo here) +0:Anonymous function arguments and command arguments +>yes +>here +>some yes +>empty +>here + %clean rm -f file.in file.out