zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh workers <zsh-workers@zsh.org>
Subject: autoload -X inside an anonymous function
Date: Tue, 18 Sep 2012 04:12:02 +0200	[thread overview]
Message-ID: <13194.1347934322@thecus.kiddle.eu> (raw)

While altering some autoloaded functions, it occurred to me to check what
would happen if you run autoload -X from inside an anonymous function.

The error message is not really what you would expect:
(eval):1: parse error near `"$@"'
Furthermore, running:
  which '(anon)'
shows that I also now have a named function named (anon).

The reason for the (eval) error message is that bin_eval is called to
run the function. This looks a bit of a hack with "$@" being passed as
an argument but also has other effects; most notable is another round
of alias expansion but you also get '(eval)' in $funcstack.

While looking at that relevant bits of code, I also wonder whether
the second call to eval_autoload is reachable code: no builtin using
bin_functions allows both the -m and -X options.

Trying to think of uses for an explicitly defined call to autoload -X,
it seems a pity you can't make it autoload a function from a differently
named file, either by first assigning to ARGV0 or passing a parameter
to autoload -X.

Oliver


             reply	other threads:[~2012-09-18  2:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-18  2:12 Oliver Kiddle [this message]
2012-09-18 16:58 ` Bart Schaefer
2012-09-19  0:35   ` Bart Schaefer
2012-09-19  2:28   ` Oliver Kiddle
2012-09-19 14:58     ` Bart Schaefer
2012-09-20 19:35       ` Peter Stephenson
2012-09-24 18:50         ` Bart Schaefer
2012-10-05 21:32           ` Peter Stephenson
2012-10-05 21:54             ` Christian Neukirchen
2012-10-07 17:51               ` Peter Stephenson
2012-10-05 22:24             ` Peter Stephenson
2012-10-06  7:56             ` Bart Schaefer

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=13194.1347934322@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --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).