From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20979 invoked from network); 13 Nov 2008 15:03:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Nov 2008 15:03:58 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 16898 invoked from network); 13 Nov 2008 15:03:53 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Nov 2008 15:03:53 -0000 Received: (qmail 20697 invoked by alias); 13 Nov 2008 15:03:49 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26039 Received: (qmail 20684 invoked from network); 13 Nov 2008 15:03:48 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 13 Nov 2008 15:03:48 -0000 Received: from mail.o2.co.uk (jabba.london.02.net [82.132.130.169]) by bifrost.dotsrc.org (Postfix) with ESMTP id 47D3080308BE for ; Thu, 13 Nov 2008 16:03:44 +0100 (CET) Received: from sc.homeunix.net (78.105.216.138) by mail.o2.co.uk (8.0.013.3) (authenticated as stephane.chazelas) id 49196F1C005EF625; Thu, 13 Nov 2008 15:07:35 +0000 Received: from chazelas by sc.homeunix.net with local (Exim 4.69) (envelope-from ) id 1L0djL-0002R4-3t; Thu, 13 Nov 2008 15:03:35 +0000 Date: Thu, 13 Nov 2008 15:03:35 +0000 From: Stephane Chazelas To: Peter Stephenson Cc: Zsh hackers list Subject: Re: [PATCH] Re: f() { ...; } > file Message-ID: <20081113150335.GD5114@sc.homeunix.net> Mail-Followup-To: Peter Stephenson , Zsh hackers list References: <20081105212036.GA4698@sc.homeunix.net> <20081113144212.GB5114@sc.homeunix.net> <200811131452.mADEqx9i030855@news01.csr.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <200811131452.mADEqx9i030855@news01.csr.com> User-Agent: Mutt/1.5.16 (2007-09-19) X-Virus-Scanned: ClamAV 0.92.1/8627/Thu Nov 13 10:42:40 2008 on bifrost X-Virus-Status: Clean 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