Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Defining function based on alias
- X-seq: zsh-workers 40316
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Defining function based on alias
- Date: Mon, 9 Jan 2017 04:02:58 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=999ckel5k7Rd21O rcXfeOIx8t5w=; b=wP1LX6xhY1W6tdwHaGpSvVkpnhUl650j+MQaABipBfSZ1TF KrdX23XtZbey3x/+b70dzOxKVC2LlLRGRP+2uDx/y2QXWIbYFyz9xKMhNVzYCBb2 oyGzi7qSRPr1DtZvyFAH30tA0sZhkv3dNxGn8w7uutfuj1CbTAwnVFiXeq8Y=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=999ckel5k7Rd21 OrcXfeOIx8t5w=; b=WzuAWZz/Ew7HPXGCRtYZSCiNp5X1x/qIkKFQ0RQSyrJRZ3 azOqd1kfrqAyTYTyX9GLLkbWlnH6pmuPUR2h2sk1TxOltWywa6gDC7q+NiZgU7IU DS9nGCdfemxuP5OQHUDJJvh0xMCrKovp2MVMyhSSJGh8HrXjFE4W+VBxaXWbE=
- In-reply-to: <170108160921.ZM11340@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: <20170107221659.1b9232da@ntlworld.com> <20170108191922.3d3de59f@ntlworld.com> <170108160921.ZM11340@torch.brasslantern.com>
Bart Schaefer wrote on Sun, Jan 08, 2017 at 16:09:21 -0800:
> On Jan 8, 7:19pm, Peter Stephenson wrote:
> }
> } I am about to commit the following, which I hope will hope will stop
> } people coming to grief with this common confusion. Please say if you
> } see any problems.
>
> OK, here's an unusual case ...
>
> alias safely:foo='[[ -n $functions[foo] ]] || foo'
>
> safely:foo() { echo this is foo only if no other foo }
>
> I hesitate to suggest further convolutions, but maybe an option to the
> alias command to "locally" switch on ALIAS_FUNC_DEF if it's actually
> *meant* to be used that way?
This case doesn't require a new option:
alias safely:foo='[[ -n $functions[foo] ]] || function foo'
> Probably not very important.
>
Another case:
% alias foo=''
% foo() echo hey
hey
Or less minimally:
% setopt NO_multifuncdef
% alias foo=''
% foo bar () :
% which -a foo bar
foo: aliased to
bar () {
:
}
Should these two behave differently when the new option is set? The
first case appeared to be a non-anonymous function definition and the
second a multifuncdef, but the alias changed the semantics.
As Bart said: probably not very important.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author