Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: grammar triviality with '&&'
01.03.2015, 21:50, "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>:
> On Mar 1, 9:01am, Ray Andrews wrote:
> }
> } I see, so it's not a 'hard' syntactic issue
>
> Actually it IS a "hard" syntactic issue, in the sense that the grammar
> for all *nix shells [1] both immemorial and standard, formally defines
> newline as equivalent to semicolon.
>
> You can demonstrate that this is the case [2] by:
>
> torch% false && ; echo AND || ; echo OR
> OR
> torch% false ; && echo AND ; || echo OR
> zsh: parse error near `&&'
>
> [1] I don't consider here "shells" written to use the syntax of other
> interpreted languages, such as shells that execute perl or php or
> python statements.
>
> [2] Actually bash throws a syntax error on that "&& ;", but both zsh
> and ksh accept it. Chet?
(Almost) pure POSIX shells like dash, posh and busybox ash also throw syntax error here. This is a direct consequence of how grammar is defined in http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10_02. Ksh and zsh are far from being POSIX shells.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author