Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zcompile does not expand aliases defined in the compiled script
- X-seq: zsh-workers 46218
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Subject: Re: zcompile does not expand aliases defined in the compiled script
- Date: Wed, 8 Jul 2020 18:59:40 +0200
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- In-reply-to: <CAN=4vMrkQUWq0X8L98FgW5g2r6x9ZTgnGcK79cfpwy5x1cuHHw@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAN=4vMrevv626MrDG=yaqJKOjs_6ayQVfiaUBBmj+yHbsn+6cw@mail.gmail.com> <CAHYJk3TZdYB9zmGjiazyfgrQo=D8i9wVC4uuDp1FMJqZ-Bw6XQ@mail.gmail.com> <CAN=4vMrkQUWq0X8L98FgW5g2r6x9ZTgnGcK79cfpwy5x1cuHHw@mail.gmail.com>
- Sender: zsh-workers@xxxxxxx
On 7/8/20, Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
> On Tue, Jul 7, 2020 at 10:28 PM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>> It is possible that you changed the example in the mail without trying
>> what you changed; if you have the statements
>> alias x=:
>> x
>> in the file x, then sourcing it (non-compiled) will work
>
> Yes, that's exactly it. Given a script like this:
>
> alias x=:
> x
>
> Sourcing it without zcompile works (`x` on the second line is
> alias-expanded), but once the script is zcompiled an attempt to source
> it results in an error (`x` doesn't get expanded).
>
> I looked at the source code of zcompile and I understand why this
> happens. It makes perfect sense when zcompiling functions. It is,
> however, surprising when zcompiling scripts.
In general it is a good idea to not use aliases in scripts and/or
functions, they are mostly intended to save typing interactively.
Small details such as the above are another reason.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author