Zsh Mailing List Archive
Messages sorted by:
Re: [bug] zcompile failes to compile
- X-seq: zsh-workers 28032
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [bug] zcompile failes to compile
- Date: Sun, 13 Jun 2010 17:42:12 +0100
- In-reply-to: <slrni19k6a.hil.joerg@xxxxxxxxxxxx>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <slrni19k6a.hil.joerg@xxxxxxxxxxxx>
On Sun, 13 Jun 2010 12:36:26 +0000 (UTC)
JÃrg Sommer <joerg@xxxxxxxxxxxx> wrote:
> % cat /tmp/test.sh
> # -*- mode: sh -*-
> echo $ZSH_VERSION
> # with this line zcompile works
> # alias ag=true
> # but with this line zcompile fails
> alias ag='LC_ALL=C true'
> if false
> alias agd=ag
> zcompile $0
> % zsh-beta -f /tmp/test.sh
> /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
Here's the long answer.
When the script is invoked, ag becomes an alias for "LC_ALL=C 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
(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 <p.w.stephenson@xxxxxxxxxxxx>
* 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
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by: