Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: grammar triviality with '&&'
On 2015-03-02 00:54:40 -0800, Bart Schaefer wrote:
> On Mar 2, 3:27am, Vincent Lefevre wrote:
> }
> } However "&& [ -e file2 ]" could constitute a list too. There is
> } currently a parse error, but zsh could have an extension to accept
> } it as being equivalent to: "[[ $? -eq 0 ]] && [ -e file2 ]". Would
> } there be anything wrong with such an extension?
>
> If nothing else, the errexit option would fail. With errexit,
>
> false
> || anything
>
> would never get beyond "false", whereas
>
> false || anything
>
> proceeds at least through "anything".
I agree that's not equivalent, but this would not be a problem
in a "if ... then" construct (though I think it's a bad idea
to use such a feature here).
> You also get strange crap like
>
> while && this; do || if && that; then || thus; fi; done
>
> which would mean what, exactly?
while [[ $? -eq 0 ]] && this; do [[ $? -ne 0 ]] || if [[ $? -eq 0 ]] && that; then [[ $? -ne 0 ]] || thus; fi; done
> Finally if it's OK to have nothing before && / ||, then it would also be
> syntactically OK to write
>
> && || && || && && ...
I disagree. Only a && or || as the first word of a list would have
a special meaning.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author