From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18331 invoked from network); 13 Nov 2008 15:14:09 -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:14:09 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 20304 invoked from network); 13 Nov 2008 15:14:03 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Nov 2008 15:14:03 -0000 Received: (qmail 25330 invoked by alias); 13 Nov 2008 15:13:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26040 Received: (qmail 25314 invoked from network); 13 Nov 2008 15:13:57 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 13 Nov 2008 15:13:57 -0000 Received: from mail.o2.co.uk (sidious.london.02.net [82.132.130.152]) by bifrost.dotsrc.org (Postfix) with ESMTP id 50D3680308BE for ; Thu, 13 Nov 2008 16:13:54 +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 49196DF1005F6547; Thu, 13 Nov 2008 15:13:33 +0000 Received: from chazelas by sc.homeunix.net with local (Exim 4.69) (envelope-from ) id 1L0dsu-0002Sa-Tk; Thu, 13 Nov 2008 15:13:28 +0000 Date: Thu, 13 Nov 2008 15:13:28 +0000 From: Stephane Chazelas To: Peter Stephenson , Zsh hackers list Subject: Re: [PATCH] Re: f() { ...; } > file Message-ID: <20081113151328.GE5114@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> <20081113150335.GD5114@sc.homeunix.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20081113150335.GD5114@sc.homeunix.net> 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 03:03:35PM +0000, Stephane Chazelas wrote: [...] > 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. [...] Sorry the proper term is "compound command". Here is the text from SUSv3: SUS> The format of a function definition command is as SUS> follows: SUS> SUS> fname() compound-command[io-redirect ...] SUS> [...] SUS> The argument compound-command represents a compound SUS> command, as described in Compound Commands. SUS> SUS> When the function is declared, none of the expansions in SUS> Word Expansions shall be performed on the text in SUS> compound-command or io-redirect; all expansions shall be SUS> performed as normal each time the function is called. SUS> Similarly, the optional io-redirect redirections and any SUS> variable assignments within compound-command shall be SUS> performed during the execution of the function itself, SUS> not the function definition. See Consequences of Shell SUS> Errors for the consequences of failures of these SUS> operations on interactive and non-interactive shells. [...] SUS> The compound-command shall be executed whenever the SUS> function name is specified as the name of a simple SUS> command (see Command Search and Execution). The operands SUS> to the command temporarily shall become the positional SUS> parameters during the execution of the compound-command; SUS> the special parameter '#' also shall be changed to SUS> reflect the number of operands. The special parameter 0 SUS> shall be unchanged. When the function completes, the SUS> values of the positional parameters and the special SUS> parameter '#' shall be restored to the values they had SUS> before the function was executed. If the special built-in SUS> return is executed in the compound-command, the function SUS> completes and execution shall resume with the next SUS> command after the function call. So, at the moment, zsh is not conformant. The patch I suggested seems to fix it but introduces some display glitches. -- Stéphane