zsh-workers
 help / color / mirror / code / Atom feed
* autoload -X inside an anonymous function
@ 2012-09-18  2:12 Oliver Kiddle
  2012-09-18 16:58 ` Bart Schaefer
  0 siblings, 1 reply; 12+ messages in thread
From: Oliver Kiddle @ 2012-09-18  2:12 UTC (permalink / raw)
  To: Zsh workers

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-10-07 17:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-18  2:12 autoload -X inside an anonymous function Oliver Kiddle
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

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).