From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14700 invoked by alias); 13 Jun 2010 17:39:35 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28032 Received: (qmail 29155 invoked from network); 13 Jun 2010 17:39:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at ntlworld.com designates 81.103.221.56 as permitted sender) Date: Sun, 13 Jun 2010 17:42:12 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: [bug] zcompile failes to compile Message-ID: <20100613174212.3c67c662@pws-pc> In-Reply-To: References: X-Mailer: Claws Mail 3.7.6 (GTK+ 2.18.9; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Cloudmark-Analysis: v=1.1 cv=1ggfb5FlKZQUfF3vzm9UBYZ2uTfLsbs/8dSljwg5+mE= c=1 sm=0 a=q8OS1GolVHwA:10 a=DogomfpGjd0A:10 a=IkcTkHD0fZMA:10 a=NLZqzBF-AAAA:8 a=AdrojuWn3F1QUrVdK_IA:9 a=fJe-WlYARKUwC_Xdfii7KzzbcNMA:4 a=QEXdDO2ut3YA:10 a=_dQi-Dcv4p4A:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 On Sun, 13 Jun 2010 12:36:26 +0000 (UTC) J=C3=B6rg Sommer wrote: > % cat /tmp/test.sh > # -*- mode: sh -*- >=20 > echo $ZSH_VERSION >=20 > # with this line zcompile works > # alias ag=3Dtrue > # but with this line zcompile fails > alias ag=3D'LC_ALL=3DC true' >=20 > if false > then > agd() > { > true > } > else > alias agd=3Dag > fi >=20 > zcompile $0 >=20 > % zsh-beta -f /tmp/test.sh > 4.3.10-dev-1-cvs0603 > /tmp/test.sh:12: parse error near `()' > /tmp/test.sh:zcompile:20: can't read file: /tmp/test.sh The short answer is you should be using "zcompile -U" to compile without expanding already defined aliases as your script is compiled. I suppose if you're compiling functions rather than scripts it's natural that that's not on by default, since the presence or absence of the -U flag matches what autoload would do. In your case as it's a script you'd probably never want alias expansion during compilation, so -U is always going to be correct (and like you I'd probably never have thought of it). Here's the long answer. When the script is invoked, ag becomes an alias for "LC_ALL=3DC true". Than agd becomes an alias for "ag". When zcompile is invoked without the -U, the agd function definition during the parsing of the file for compilation is alias-expanded in two steps to LC_ALL=3DC true() { true } (It's never going to be executed in that particular test code but this is just the parsing phase.) In older shells parsing this didn't give an error---but I'm pretty sure it's not what you wanted it do anyway. In the current shell it does give an error. This was deliberate (and almost a year ago---it's high time I made a new release): 2009-07-17 Peter Stephenson * users/14240: Src/parse.c: assignment before a function definition should be an error, in common with other complex functions and as documented. Seeing what you've got, I think that new error is actually useful for you, too. --=20 Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/