zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: zcompile does not expand aliases defined in the compiled script
Date: Wed, 8 Jul 2020 18:59:40 +0200	[thread overview]
Message-ID: <CAHYJk3RvfY=NsxD5W+dN3kz4jW7FH4VAeOccGpdhgq0rpBwmJQ@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMrkQUWq0X8L98FgW5g2r6x9ZTgnGcK79cfpwy5x1cuHHw@mail.gmail.com>

On 7/8/20, Roman Perepelitsa <roman.perepelitsa@gmail.com> wrote:
> On Tue, Jul 7, 2020 at 10:28 PM Mikael Magnusson <mikachu@gmail.com> 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

      reply	other threads:[~2020-07-08 17:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 10:00 Roman Perepelitsa
2020-07-07 20:28 ` Mikael Magnusson
2020-07-08  5:18   ` Roman Perepelitsa
2020-07-08 16:59     ` Mikael Magnusson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHYJk3RvfY=NsxD5W+dN3kz4jW7FH4VAeOccGpdhgq0rpBwmJQ@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=roman.perepelitsa@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).