Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Re: f() { ...; } > file
- X-seq: zsh-workers 26039
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Peter Stephenson <pws@xxxxxxx>
- Subject: Re: [PATCH] Re: f() { ...; } > file
- Date: Thu, 13 Nov 2008 15:03:35 +0000
- Cc: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- In-reply-to: <200811131452.mADEqx9i030855@xxxxxxxxxxxxxx>
- Mail-followup-to: Peter Stephenson <pws@xxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20081105212036.GA4698@xxxxxxxxxxxxxxx> <20081113144212.GB5114@xxxxxxxxxxxxxxx> <200811131452.mADEqx9i030855@xxxxxxxxxxxxxx>
On Thu, Nov 13, 2008 at 02:52:59PM +0000, Peter Stephenson wrote:
> Stephane Chazelas wrote:
> > The patch below seems to fix it. It just removes the special
> > case of f() { }. I don't why it was there in the first place.
> > rev 1.1 of parse.c already had it.
>
> That's because you've made all functions with braces parse as if they
> contain current shell structures; you'll see they're output with an
> unnecessary extra set of "{"s. This works because it just makes the
> code behave like the non-confusing way to do it, with the redirection
> inside the function.
[...]
Well, it depends how you regard the function syntax.
In the Bourne shell and its derivatives, defining a function
is really sticking foo() in front of a command. The "{" and "}"
are not part of the syntax of a function definition.
Note that POSIX has specified it with a restriction in that you
can only stick "foo()" in front of complex command, and bash is
the only shell to enforce that restriction.
bash allows:
foo() for i do echo "$i"; done
but not
foo() echo "$*"
contrary to all the other Bourne like shells which allow both.
Now, I agree that
$ /tmp/Z/bin/zsh -c 'f() { :; }; typeset -f'
f () {
{
:
}
}
is not ideal ;). Looks like the fix is not as easy as that.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author