zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: syntax error with anonymous functions when an argument begins with (
Date: Wed, 27 Jul 2011 20:22:38 +0100	[thread overview]
Message-ID: <20110727202238.37c469d0@pws-pc.ntlworld.com> (raw)
In-Reply-To: <CAHYJk3S8rbpowTZNH1mvWZisobDuSJqyNEZK2P+OOKZgPTMa6w@mail.gmail.com>

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


  reply	other threads:[~2011-07-27 19:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-27 16:48 Mikael Magnusson
2011-07-27 19:22 ` Peter Stephenson [this message]
2011-07-31 14:17 Jilles Tjoelker
2011-07-31 18:39 ` Peter Stephenson
2011-08-08  4:29   ` Mikael Magnusson
2011-08-08  8:34     ` Peter Stephenson
2011-08-08  8:40       ` Mikael Magnusson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110727202238.37c469d0@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).