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

grammar triviality with '&&'



I notice that zsh is quite tolerant as far as most
line wrap situations go, except for this:

    [ -e file1 ] &&
    [ -e file2 ] &&
    echo 'both files exist'

... good

    [ -e file1 ]
    && [ -e file2 ]
    && echo 'both files exist'

... syntax error, but we can fix it like this:

    [ -e file1 ]\
    && [ -e file2 ]\
    && echo 'both files exist'

I'm wondering why the line continuation is strictly necessary.
IOW, why doesn't the parser permit the '&&' on a new line?
I've been trying to come up with something that would
cause an ambiguity if it were permitted, but can't find anything,
but I doubt the rule would be there otherwise.



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