From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9707 invoked by alias); 2 Mar 2015 03:12:32 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19944 Received: (qmail 19382 invoked from network); 2 Mar 2015 03:12:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=windows-1252; format=flowed X-Authority-Analysis: v=2.1 cv=T/C1EZ6Q c=1 sm=1 tr=0 a=v3jdlwE+mftNnR1sUa1KMQ==:117 a=v3jdlwE+mftNnR1sUa1KMQ==:17 a=VNsaWKQvMhEA:10 a=N659UExz7-8A:10 a=qBGxxJi2CwxRcwcUgPMA:9 a=pILNOxqGKmIA:10 Message-id: <54F3D518.9030400@eastlink.ca> Date: Sun, 01 Mar 2015 19:12:24 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.4.0 To: zsh-users@zsh.org Subject: Re: grammar triviality with '&&' References: <54F33934.2070607@eastlink.ca> <13666281425228233@web7o.yandex.ru> <54F345D3.9010204@eastlink.ca> <20150302022754.GA7449@xvii.vinc17.org> In-reply-to: <20150302022754.GA7449@xvii.vinc17.org> On 03/01/2015 06:27 PM, Vincent Lefevre wrote: > On 2015-03-01 13:49:38 -0500, Lawrence Velázquez wrote: >> On Mar 1, 2015, at 12:01 PM, Ray Andrews wrote: >> [...] From zshmisc(1): >> >> A list is a sequence of zero or more sublists, in which each sublist >> is terminated by `;', `&', `&|', `&!', or a newline. >> >> In your second example, `[ -e file1 ]` constitutes a list. > 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? > > Similarly, "|| X" could be regarded as equivalent to > "[[ $? -ne 0 ]] || X" by zsh. > I always thought of '&&' as logically equivalent to a keyword 'andif' and '||' as 'orif' which is why I like to put them first on a line, because we always put keywords first (mostly), but it seems to me that even with Bart's definition of a 'hard' syntax problem with the de-facto semicolon, if [ -e file ] ... by itself on a line is legal, and if it returns success or failure and if that success or failure is there for checking on the next line, the '&&' could mean nothing else but 'check previous true/false', so it should be unambiguous, so why wouldn't it be legal? It would be the same as: [ -e file ]; && .... ... which throws an error, but where is the ambiguity? What else could it mean? Seems to me the semi doesn't/shouldn't change anything. BTW, is there somewhere to read up on the 'list' idea, it's the first I've ever heard of that concept.