Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How should empty aliases work?
- X-seq: zsh-workers 42206
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: How should empty aliases work?
- Date: Wed, 03 Jan 2018 11:47:25 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180103114729euoutp01d43b5be621821163ed8b194dbdf9ce1e~GSlQMiEX21424414244euoutp018
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1514980049; bh=hUiagx/KO1XKTpwQcu0TYRfaoz1DKPfQfJm+Ti+1kr8=; h=Date:From:To:Subject:In-reply-to:References:From; b=cXsUCR3KKNmopkqCw49XjTnnI0Roo19nJ8EvkVZs+HDKXOei1CyPUA5Rv+5OWdczB GrY+KH6dLkyThJ+A83FR2AwA1rtpBRNgl8Oc9ucTuFQbSH5REMxws53+RSlYwHbw+z MvgFg1IUr1Uu1oAOmJDUx1LuzjYilxnDpVLZ2jYs=
- In-reply-to: <CAH+w=7bB+FugYxHnw-6WWLYU3DoCxv_FangQiDcRWN=LR+Hvig@mail.gmail.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>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <CAH+w=7bNy-66-v=QX2BDzkbJ5SadK7mVgd9joHGgF07364PV0w@mail.gmail.com> <CGME20171230011519epcas5p42158c41e36e278fe83d86257f419cd74@epcas5p4.samsung.com> <CAH+w=7bB+FugYxHnw-6WWLYU3DoCxv_FangQiDcRWN=LR+Hvig@mail.gmail.com>
On Fri, 29 Dec 2017 17:14:38 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Fri, Dec 29, 2017 at 12:30 AM, Bart Schaefer
> <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > % alias empty=''
> > % alias output='empty echo'
> > % alias echo='print -r bar'
> > % output foo
> >
> > What actually happens is that "echo" expands and "print -r bar foo" is
> > executed. If that's correct, can someone explain why?
>
> I think the answer is that being a word in command position has
> precedence over being a word preceded by an alias replacement. Words
> in command position are always alias-replaceable; words not in command
> position are alias-replaceable if preceded by an alias replacement
> that ended with a space.
>
> So when "empty" disappears, it leaves "echo" in command position and
> the first clause applies even though the second clause does not.
Yes, when we get to "echo" we have no remaining knowledge that we've
expanded an alias. The documentation simply refers to an alias being
expanded "if it is in command position [or a global alias]", with no
reference to preceding aliases. So I think everything is as it should
be.
Consider also
alias foo="echo alias expanded;"
% foo foo
alias expanded
alias expanded
which is just following the same rules.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author