Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: unmatched '

On 09/03/18 07:20 PM, Aaron Schrab wrote:

No, that file is not included in any Debian package:
So I've since discovered.  God knows where it came from, it's nothing of mine, that's for sure.  Apologies to Debian for the suggestion.  I've since killed it.

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
   __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.

Messages sorted by: Reverse Date, Date, Thread, Author