Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Seeking feedback word breaks and aliasing of tokens

On 27 Mar, Bart wrote:
> "alias" builtin, namely the ability to create aliases for tokens that
> are part of the basic pipeline syntax.

> There is an additional effect of this feature, illustrated by:
> % alias -g '||'='OR'
> % print no||yes
> no ORyes
> % 
> Note that a word break is introduced to the left of the expansion (because
> of '||'s original meaning as shell syntax) even though there are no spaces
> around the original usage; but no word break occurs to the right of the
> expansion.  The proposal is for word breaks on both sides of the expansion
> (as is implied by recognition of a separately aliasable word).

The added word breaks do remove flexibility because you could always
have included them in the alias: alias -g '||'=' OR '

One possible use might be to disable ||, perhaps for a restricted shell
such as with alias -g '||'='\|\|'
in that case you wouldn't want the added spaces.

I'd agree that 34781 made sense in that having the word break on only
one side of the token after alias expansion is not consistent. Was the
preceding word break always there or intentional as part of the recent

It seems redirections are also covered by this change but this looks
like a bug:
% alias -g '>!'='REDIR'
% echo one>!two
zsh: event not found: two
 prompt.c:1539: BUG: cmdstack empty

You can't alias something like 2>&1 though.

alias -g '&'='&!'
doesn't have the same problem and I could see someone finding that


Messages sorted by: Reverse Date, Date, Thread, Author