Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How should empty aliases work?
- X-seq: zsh-workers 42184
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: How should empty aliases work?
- Date: Fri, 29 Dec 2017 17:14:38 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=CCnSyny/x/pjWl31+mMR8MyVwDIbtR+20t2Ed8DPTWY=; b=rhXIiVDx9Uj9GHF+dxfOGao7Co2hIdGC6zJRf9Lw/cxEstBvinZIx2Ty9FI2FUygQH IOdDSIVIBfDOhHBOdPDk8gFDQJPTpeBZm6TgEOf54/jzh0bCMxyRj+hoNQpLIdJFMHlb h2HuDL3oXck6cONht5GIHXM7TV4vTTU21HZ84Hn3NruNJP/N4kTGESUrxzNnYbYER5CZ LiN/MqEeHYKdDEuScOKE9dbt9CTj6KfstV6RaxHkri8sOn8g7o0dlahyOZ5lprXU8Dme GborC3F+01D0aaixg7Y6sxLsDC67FfA1fbKsrCw+UV4kNv02cYYsp25je3Iu9FY3tPpI GI/w==
- In-reply-to: <CAH+w=7bNy-66-v=QX2BDzkbJ5SadK7mVgd9joHGgF07364PV0w@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
- References: <CAH+w=7bNy-66-v=QX2BDzkbJ5SadK7mVgd9joHGgF07364PV0w@mail.gmail.com>
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author