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