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

PATCH: Re: function declaration syntax



Peter Stephenson wrote:

> Did anybody notice that according to the manual (and the reference card,
> which was how I noticed) this was supposed to work?
> 
> % fn() print foo
> # Looks like it worked...
> % which fn
> fn() {
>        print foo
> }
> # but it doesn't.
> % fn
> % 
> 
> Either we should fix it or remove it.

My fault, I guess. I have a faint memory of having tested it, but that 
was probably before the last changes to the word code stuff.

Bye
 Sven

P.S.: The comments in parse.c talk about a list1 being allowed there,
      which would be a sublist.  The manual says it's a command. It
      would be easy to change...

Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.9
diff -u -r1.9 parse.c
--- Src/parse.c	2000/06/14 09:26:56	1.9
+++ Src/parse.c	2000/06/29 12:05:34
@@ -1516,10 +1516,11 @@
 		}
 		yylex();
 	    } else {
-		int ll, sl, c = 0;
+		int ll, sl, pl, c = 0;
 
 		ll = ecadd(0);
 		sl = ecadd(0);
+		pl = ecadd(WCB_PIPE(WC_PIPE_END, 0));
 
 		par_cmd(&c);
 
Index: Test/09funcdef.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/09funcdef.ztst,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 09funcdef.ztst
--- Test/09funcdef.ztst	2000/01/31 11:46:35	1.1.1.1
+++ Test/09funcdef.ztst	2000/06/29 12:05:35
@@ -6,3 +6,8 @@
   f$$
 0:Regression test: `function f$$ () { ... }'
 >regress expansion of function names
+
+  function foo () print bar
+  foo
+0:Function definition without braces
+>bar

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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