0

I work connected to a grid running RHEL 5.7 and it has grep 2.5.1 available. I have configured a GREP_COLOR variable to highlight matches in green and alias grep = "grep --color -nri".

It works fine but when I try to search for a camelcase text, the color highlighting doesn't work and it outputs everything on white letters. But if I put the same text all in lowercase it is highlighted (-i flag works).

Does anyone knows why should this happen?

Thanks !


Edit: To be more explicit here is an example:

On my .bashrc I have this :

export GREP_COLOR='01;33'
alias grep="grep --color -nri"

If I try to find a text like 'someTestExample' in the current directory and its children:

$ grep 'someTestExample' . #returns what it found without highlighting 
$ grep 'sometestexample' . #highlighted output

screenshot

avalencia
  • 33
  • 8
  • What is `GREP_COLOR` set to? Can you provide an [MCVE](https://stackoverflow.com/help/mcve) file and commands that show this behavior? – Etan Reisner Nov 10 '15 at 17:00
  • `grep --color` needs an argument: either "never", "always" or "auto". Not sure what is the behaviour if you don't give any – fedorqui Nov 10 '15 at 19:11
  • @EtanReisner Sorry, I added some more clarifying info. @fedorqui Actually it can work just adding the `--color` option. Nevertheless I tried to force it setting `--color=always` and still the same behavior – avalencia Nov 10 '15 at 22:09
  • Those both work for me on CentOS 5. What do you see if you pipe the `grep` output to `cat -A` (you'll need to use `--color=always` for this)? – Etan Reisner Nov 11 '15 at 02:41

1 Answers1

0

This apparently is a bug related to the -i flag. When I removed it from my alias the camelCase highlighting works as it should.

As the grep version I'm using is pretty old, probably on newer version this is already fixed.

So, the way I fixed this is removing the -i flag from my alias.

avalencia
  • 33
  • 8