From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25482 invoked by alias); 2 Mar 2015 16:17:50 -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: 19954 Received: (qmail 19231 invoked from network); 2 Mar 2015 16:17:45 -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,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 MIME-version: 1.0 Content-type: multipart/alternative; boundary="Boundary_(ID_UYwZZ61mzt8zTsd3Qk+x1Q)" X-Authority-Analysis: v=2.1 cv=X+5rdgje c=1 sm=1 tr=0 a=jzv7pUNyk+0Y+COVCE1LmA==:117 a=jzv7pUNyk+0Y+COVCE1LmA==:17 a=VNsaWKQvMhEA:10 a=r77TgQKjGQsHNAKrUKIA:9 a=9iDbn-4jx3cA:10 a=cKsnjEOsciEA:10 a=gZbpxnkM3yUA:10 a=Y5I9DRp-fDtNLdx-XpwA:9 a=QEXdDO2ut3YA:10 a=pGLkceISAAAA:8 a=oKBLULy3oF0i_m3rYboA:9 a=OWXhnqzoyu8amWWL:21 a=_W_S_7VecoQA:10 Message-id: <54F48D26.6040303@eastlink.ca> Date: Mon, 02 Mar 2015 08:17:42 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.4.0 To: Kurtis Rader Cc: Zsh Users Subject: Re: grammar triviality with '&&' References: <54F33934.2070607@eastlink.ca> <13666281425228233@web7o.yandex.ru> <54F345D3.9010204@eastlink.ca> <20150302022754.GA7449@xvii.vinc17.org> <54F3E489.5050603@eastlink.ca> In-reply-to: --Boundary_(ID_UYwZZ61mzt8zTsd3Qk+x1Q) Content-type: text/plain; CHARSET=US-ASCII; format=flowed Content-transfer-encoding: 7BIT On 03/01/2015 09:22 PM, Kurtis Rader wrote: > > One obvious cost is that anyone reading a script that uses the feature > will naturally assume the author made a mistake and the script is > invalid. So don't use it if, when or where tradition trumps practicality--which is almost everywhere. > The reason this restriction exists is not arbitrary. That may very well be the case, which is why I raised the question, but it seems that it might not be the case after all (Lawrence). I'm over fascinated by this sort of minutia. > It is a an obvious and natural consequence of how the grammar was > interpreted by the person(s) who wrote the code for the Bourne-shell, > Bash, Zsh, etcetera. Why is it simpler for the code to "just grab the > errorlevel of the previous command" when it sees a leading "&&" or "||"? But is that not what it already does? The question is whether a line break or a semi *necessarily* prevents that. IOW, what ambiguity would this cause: [ -e file1 ] && [ -e file2 ] > Also, it is not just a matter of changing the zsh implementation. Unit > tests need to be added and existing tests likely updated. > Documentation needs to be changed. Whether the change might break > existing uses has to be carefully considered. Absolutely, and that is probably reason enough why it won't happen. It would have to be nothing more than a relaxation of an arbitrary rule ( **if** it is arbitrary)--maybe there is a very good reason why errorlevel can't be passed beyond a newline or semi. If there is such a good reason, I'd be educated to learn what it is. But since "[[ $? -eq 0 ]]" works past the newline, at this point I can't see what the linewrap would *necessarily* break. > > You say "I'd use it for sure". Please provide a non-contrived example, > preferably two or three, where this would be useful. if [ -e 'shelly.txt' ] && [ -n "$ozymandias" ] && [ grep "I met a traveler" ] then echo "Look on my works, ye mighty" fi ... I have a trivial preference for that form, I find it neater. It is very unimportant. > How hard is it to be explicit and include the "[[ $? -eq 0 ]]" in a > script? If this feature were truly useful for interactive use I might > agree with you. But I see no evidence and my 30+ years experience that > it has no use outside of making a tiny percentage of scripts a few > characters shorter. Exactly so. Whereas I'd like it for saving me the line continuation backslash, that is monumentally trivial, I'm interested in the theory of the thing. I like Lawrence's thinking on the matter, however. Don't take this more seriously than I take it. --Boundary_(ID_UYwZZ61mzt8zTsd3Qk+x1Q)--