grep --color=auto with -i option disables the matching text color, why?

Posted by emptyset on Super User See other posts from Super User or by emptyset
Published on 2009-11-20T20:12:17Z Indexed on 2011/11/16 17:57 UTC
Read the original article Hit count: 272

Filed under:
|
|
|

I was messing around with grep and put this in my .zshenv:

export GREP_OPTIONS="--color=auto"
export GREP_COLORS='mt=1;34'

I was bonking my head on the keyboard and changing GREP_COLORS around for a minute trying to figure out why the folder colors were working, but the matching text wasn't.

I was doing this:

$ grep -R -n -i -e "functionFoo\(" --include=*.cs --exclude-dir=Logs *

The line number and file names were set with the default colors, but the matching text wasn't.

After spending way too much time, I thought to do this:

$ grep -R -n -e "functionFoo\(" --include=*.cs --exclude-dir=Logs *

(I removed the -i option.) That's all it took to get the matching text to correctly show up in bold blue. This is a Cygwin on Vista setup, with rxvt running zsh.

Any idea why grep colors would break on specifying a case-insensitive match?

Update: Under cygwin 1.7, it's a little bit better - case insensitive search works correctly, but it only highlights the word that matches the expression exactly. In other words, "FunctionFoo" highlights "FunctionFoo" but not "functionFoo" and vice versa. Probably a grep issue so I'll be submitting it to that list.

© Super User or respective owner

Related posts about windows-vista

Related posts about cygwin