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

Re: grammar triviality with '&&'



On Wed, 4 Mar 2015 17:51:12 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Mar 4,  3:47pm, Vincent Lefevre wrote:
> }
> } I've found a bug:
> } 
> } % alias '&&=(){ return $? } && '
> } % && echo OK
> } zsh: parse error near `&&'
> 
> Although I see PWS has already made a (broken?) stab at changing this,
> I think that's a documentation omission rather than a code bug.  Some
> things intentionally cannot be aliased.

I don't think that makes sense: there's too much you already can alias.
You can alias reserved words and arbitrary magic sequences like \&, for
example, and consequently already have the power to do as much damage as
you like.  Forbidding it in this case would just be providing an
unmemorable list of special cases.

I suspect this dates back to very early days when the shell was much
weaker on translating lexical tokens back to to text.

pws



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