zsh-users
 help / color / mirror / code / Atom feed
From: Aaron Schrab <aaron@schrab.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: zsh-users@zsh.org
Subject: Re: unmatched '
Date: Fri, 9 Mar 2018 22:20:41 -0500	[thread overview]
Message-ID: <20180310032041.GF16478@pug.qqx.org> (raw)
In-Reply-To: <18dac66c-f348-8123-c051-4deb3dd21294@eastlink.ca>

At 14:45 -0800 09 Mar 2018, Ray Andrews <rayandrews@eastlink.ca> 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 "$@"


  parent reply	other threads:[~2018-03-10  3:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09 17:50 Ray Andrews
2018-03-09 20:23 ` Bart Schaefer
2018-03-09 22:45   ` Ray Andrews
2018-03-09 23:12     ` Ray Andrews
2018-03-10  3:20     ` Aaron Schrab [this message]
2018-03-10  3:51       ` Ray Andrews
2018-03-10 17:40         ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180310032041.GF16478@pug.qqx.org \
    --to=aaron@schrab.com \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).