Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: autoload -X inside an anonymous function
- X-seq: zsh-workers 30680
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: autoload -X inside an anonymous function
- Date: Wed, 19 Sep 2012 03:28:46 +0100 (BST)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1348021726; bh=m3h9Om6WJ3O29n5sDqh7FpIKia52HSGKxPJIeCiNSVA=; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=ohhi0htgDvEyLDF+L9ZUNaJpLvBHZb+gPfDZoz0XGNEEwka92T/CjPVZpnJ8CWn4ALPUBPYDSc8oidBEKU7m0z2Rzw8XFMcDfwXJQ2sMCo6mzLPD/8AtASh1UK6A8BgfyOQFydxw9MpyMd49Fd19+qRVd0I+ogGph0Z98x0UYSY=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=rCUFUZCN/XiLYRneuboJ2vzdEtm9QF4qb9c4WA2YwACiiuNigE66M9fJXlAPwLlyOicD6IqwpEEYiNLB6uFhZ5viMNLkCtxovXRc455rrJo/JiW8EcYNx7KIM/rMMpqOJXN6jh13G61iA4CFGVynelWgfUmVxgyL6MbU8VhIpcQ=;
- In-reply-to: <120918095827.ZM23535@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <13194.1347934322@thecus.kiddle.eu> <120918095827.ZM23535@torch.brasslantern.com>
- Reply-to: Oliver Kiddle <okiddle@xxxxxxxxxxx>
Bart wrote:
> Aside mostly to PWS: Is there any way to detect that you are in the
> anonymous function? (!scriptname) means you aren't in any function at
> all, which is what bin_functions() is testing for. Using strcmp() is
> not ideal, since one actully is permitted to create a function named
> '(anon)' [though it would be ugly/confusing to call it].
It might be better to use a named constant for the string "(anon)" so
that a pointer comparison can be used instead of strcmp(). Either that
or add space for flags in the shfunc structure.
> IIRC the extra pass of alias expansion was discounted because by the
> time you invoke "autoload -X" you presumably have alreay reached the
> function via a name that isn't an alias.
It is a bit of a hack, though. I couldn't see an alternative without
making functions in exec.c non-static.
> } 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.
>
> It definitely is not reachable because of the test at about line 2686 in
> builtin.c -- the second eval_autoload likely is there for completeness
> (in case somebody later adds a builtin that allows a mass autoload).
I would have assumed it was a cut and paste remnant from when -m was
implemented. I can't see any reason why it wouldn't work if you simply
added -m to the list of options accepted by autoload (or -X to
functions). Not that it'd be especially useful; even your "autoload -m
+X \*" example is perhaps only useful for checking there's no parse
errors in any functions.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author