From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5345 invoked by alias); 10 Mar 2018 18:10:25 -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: 23229 Received: (qmail 22661 invoked by uid 1010); 10 Mar 2018 18:10:25 -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 1.294203 secs); 10 Mar 2018 18:10:25 -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=OKgJIxSB c=1 sm=1 tr=0 a=RnRVsdTsRxS/hkU0yKjOWA==:117 a=RnRVsdTsRxS/hkU0yKjOWA==:17 a=IkcTkHD0fZMA:10 a=If6MYW9zAc4xeVFbaGEA:9 a=QEXdDO2ut3YA:10 X-EL-IP-NOAUTH: 24.207.101.9 Subject: Re: unmatched ' To: zsh-users@zsh.org References: <2dcec644-7acb-5916-2858-2301206f1da8@eastlink.ca> <18dac66c-f348-8123-c051-4deb3dd21294@eastlink.ca> <20180310032041.GF16478@pug.qqx.org> From: Ray Andrews Message-id: <72253ae6-ec4b-0f00-a7f5-9d917afdb565@eastlink.ca> Date: Sat, 10 Mar 2018 09:40:18 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 In-reply-to: Content-language: en-CA On 09/03/18 07:51 PM, Ray Andrews wrote: > On 09/03/18 07:20 PM, Aaron Schrab wrote: >> >> #!/bin/zsh -u >> # Multi-color grep >> >> __mcgrep() { >>  local color=$1; shift >>  local pattern="$1"; shift >> >>  if [[ $# = 0 ]]; then >>    # No more patterns, just pass through the input >>    cat >>  else >>    __mcgrep $((color + 1)) "$@" >>  fi | >>    GREP_COLOR="01;$color" grep --color=always "$pattern" >> } >> >> # Start with yellow, then blue, magenta, cyan. >> __mcgrep 33 "$@" >> > Thanks, that's interesting, I'll experiment with it tomorrow. > > > That sure got me thinking.  At the very least I can drop 'eval' by looping:     for file in "$@"; do         foo=( `print -l $foo | GREP_COLOR='01;'$ccolor grep --color=always $file` )         bar=( `print -l $bar | GREP_COLOR='01;'$ccolor grep --color=always $file` )         (( ccolor++ )) # Next color.     done ... it seems that one pipe at a time is fine, so rather than create the chain of pipes ahead of time, and try to pass it via $grepstring, if I just loop, everything is fine.  My entire function ends up 600 bytes shorter and the whole thing is much easier to read.