From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 496 invoked by alias); 19 Feb 2018 21:12:29 -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: List-Unsubscribe: X-Seq: 23148 Received: (qmail 26208 invoked by uid 1010); 19 Feb 2018 21:12:29 -0000 X-Qmail-Scanner-Diagnostics: from mta03.eastlink.ca by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(24.224.136.9):SA:0(-2.6/5.0):. Processed in 4.40092 secs); 19 Feb 2018 21:12:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) 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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: rayandrews@eastlink.ca X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=utf-8; format=flowed X-Authority-Analysis: v=2.3 cv=dfKuI0fe c=1 sm=1 tr=0 a=RnRVsdTsRxS/hkU0yKjOWA==:117 a=RnRVsdTsRxS/hkU0yKjOWA==:17 a=IkcTkHD0fZMA:10 a=Nkj2a2CZSFyEKfpC06gA:9 a=QEXdDO2ut3YA:10 X-EL-IP-NOAUTH: 24.207.101.9 To: Zsh Users From: Ray Andrews Subject: &&|| Message-id: <64c5472a-b174-00b6-7ab0-b65d664be675@eastlink.ca> Date: Mon, 19 Feb 2018 13:12:20 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 Content-language: en-CA function test () {     _aaray=`ls`     [ true ] && { print -l "${ _aaray[@]}" | GREP_COLOR='01;33' egrep --color=always "$1"\ | GREP_COLOR='01;31' egrep --color=always "$2" }\ || echo bust! } $ touch present $ test present pres present                            << two colors. $ test present pppres bust! $ test pppresent p bust! When I first did this, I was puzzled by the output, then I wisely realized that the  '||'  was in fact responding to the return value of the failed egrep.  At first I did this without the braces and was content with what happened but I'd expect the braces to force the '||' to respond to the leading test (which of course never varies here being true all the time) and thus never give me a 'bust!' regardless of the egrep return value.  I solved the issue by using an 'if/else' construction but still I'm curious about the above.  Is my expectation mistaken?  Within an '&& ||' construction how would I write that to do as I was expecting -- respond to the truth value of the initial test?  When I use braces in complex '&& ||' situations they always seem to behave as expected.  I do have the niggling feeling my expectation above is wrong, but I can't quite say why.