From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8843 invoked from network); 20 Jul 2009 08:29:27 -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.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 20 Jul 2009 08:29:27 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 94805 invoked from network); 20 Jul 2009 08:29:11 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 20 Jul 2009 08:29:11 -0000 Received: (qmail 13092 invoked by alias); 20 Jul 2009 08:29:01 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27174 Received: (qmail 13068 invoked from network); 20 Jul 2009 08:28:59 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 20 Jul 2009 08:28:59 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [85.115.60.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 327FE8027106 for ; Mon, 20 Jul 2009 10:28:53 +0200 (CEST) Received: from rly05d.srv.mailcontrol.com (localhost.localdomain [127.0.0.1]) by rly05d.srv.mailcontrol.com (MailControl) with ESMTP id n6K8SWKL015891 for ; Mon, 20 Jul 2009 09:28:49 +0100 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by rly05d.srv.mailcontrol.com (MailControl) id n6K8SAnx013459 for ; Mon, 20 Jul 2009 09:28:10 +0100 Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly05d-eth0.srv.mailcontrol.com (envelope-sender ) (MIMEDefang) with ESMTP id n6K8RwI0013212; Mon, 20 Jul 2009 09:28:10 +0100 (BST) Received: from news01 ([10.99.50.25]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Mon, 20 Jul 2009 09:27:57 +0100 Date: Mon, 20 Jul 2009 09:27:57 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Cc: martin f krafft , 537596@bugs.debian.org Subject: Re: Bug#537596: regression: parse error near `()' in function definition Message-ID: <20090720092757.77e812c7@news01> In-Reply-To: <20090719232041.GA5156@scru.org> References: <20090719171651.GA7217@piper.oerlikon.madduck.net> <20090719232041.GA5156@scru.org> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 20 Jul 2009 08:27:57.0728 (UTC) FILETIME=[FC697A00:01CA0913] X-Scanned-By: MailControl A-09-20-00 (www.mailcontrol.com) on 10.68.1.115 X-Virus-Scanned: ClamAV 0.94.2/9589/Sun Jul 19 05:14:56 2009 on bifrost X-Virus-Status: Clean On Sun, 19 Jul 2009 23:20:41 +0000 Clint Adams wrote: > On Sun, Jul 19, 2009 at 07:16:51PM +0200, martin f krafft wrote: > > % eval 'lt() { (_lt-en $*; _en-lt $*) | more }' > > zsh: parse error near `()' > > > > Alright, so lt is special: > > > > % which lt > > lt: aliased to ls -lt Assuming lt was defined as an alias first, this has always been the wrong thing to do: % alias lt="one two" % eval 'lt() { (_lt-en $*; _en-lt $*) | more }' % which one two one () { ( _lt-en $* _en-lt $* ) | more } two () { ( _lt-en $* _en-lt $* ) | more } This is not a new feature; it's been mentioned in the FAQ for many years. 2.3: Why do my csh aliases not work? (Plus other alias pitfalls.) ... There is one other serious problem with aliases: consider alias l='/bin/ls -F' l() { /bin/ls -la "$@" | more } `l' in the function definition is in command position and is expanded as an alias, defining `/bin/ls' and `-F' as functions which call `/bin/ls', which gets a bit recursive. This can be avoided if you use `function' to define a function, which doesn't expand aliases. It is possible to argue for extra warnings somewhere in this mess. Bart Schaefer's rule is: Define first those aliases you expect to use in the body of a function, but define the function first if the alias has the same name as the function. -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK 'member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom'