Zsh Mailing List Archive
Messages sorted by:
autoload -X inside an anonymous function
- X-seq: zsh-workers 30675
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: autoload -X inside an anonymous function
- Date: Tue, 18 Sep 2012 04:12:02 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1347934323; bh=axetnBxnrKjsOl4S/mT5G+R5ccQTy0Bbg82FTeUc4aw=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:From:To:Subject:MIME-Version:Content-Type:Content-ID:Date:Message-ID; b=RgXnWhYwRSrqvmBsEvdEuVqns4VndDDuLGamdF8p2uus6KguZKfLHA9ydulJcXQ1ZQUK9BH5DZrqup81sLtEpT9AODfdeqmbnt6Bz/Shu8adSSFFMS9WOF03TSsCc53p18cGdyhw36hu+IqzI6X8ciTjzJ6K4yd6ZorSeb0Lnsg=
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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 `"$@"'
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.
Messages sorted by: