From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29072 invoked by alias); 10 Mar 2018 03:28:19 -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: 23227 Received: (qmail 4184 invoked by uid 1010); 10 Mar 2018 03:28:19 -0000 X-Qmail-Scanner-Diagnostics: from pug.qqx.org 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(50.116.43.67):SA:0(-1.9/5.0):. Processed in 8.277495 secs); 10 Mar 2018 03:28:19 -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=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SPF_HELO_TEMPERROR autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: aaron@schrab.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Date: Fri, 9 Mar 2018 22:20:41 -0500 From: Aaron Schrab To: Ray Andrews Cc: zsh-users@zsh.org Subject: Re: unmatched ' Message-ID: <20180310032041.GF16478@pug.qqx.org> Mail-Followup-To: Ray Andrews , zsh-users@zsh.org References: <2dcec644-7acb-5916-2858-2301206f1da8@eastlink.ca> <18dac66c-f348-8123-c051-4deb3dd21294@eastlink.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <18dac66c-f348-8123-c051-4deb3dd21294@eastlink.ca> User-Agent: Mutt/1.9.4+113 (e7da115bc) (2018-03-06) At 14:45 -0800 09 Mar 2018, Ray Andrews wrote: >>Why are you putting stuff like that file in /etc/ in the first place? > >Heck, not me!  That's stock Debian, I'd not create a directory like >that on pain of damnation.  Debian should not allow it either, IMHO. No, that file is not included in any Debian package: https://packages.debian.org/search?searchon=contents&keywords=DSHR&mode=filename&suite=stable&arch=any >    ccolor=33      # Start with yellow, then blue, magenta, cyan. >    for file in "$@"; do >        # We colorize the already selected lines here: >        grepstring="$grepstring | GREP_COLOR='01;'"$ccolor" grep >$wwild $ccase --color=always \"$file\"" >        (( ccolor++ )) # Next color. >    done > >... so I'm filtering and colorizing however many arguments there are >to the command, so each iteration must (?) begin with the pipe.  And >the final string: Perhaps something like the following? This doesn't include the doing the find(1), instead it's designed to get the text to search on STDIN. It also doesn't use the $wwild or $ccase variables, which I didn't see defined anywhere. But that would be easy to add. No use of eval here. Besides being safer, that also tends to be more readable; although the use of recursion here cuts down on that improvement. Despite having zsh on the #! line, this would work with bash as well. #!/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 "$@"