[mdlug] grep bug?

Robert Citek robert.citek at gmail.com
Wed Apr 16 16:33:39 EDT 2008


Hello all,

I was running grep on my Ubuntu 7.10 box the other day and came across
some rather bizarre behaviour.  If I ran this grep command, everything
worked just fine:

$ echo hello | grep --color=always -e ^

However, if I make grep case-insensitive, grep seems to hang:

$ echo hello | grep -i --color=always -e ^

A little sleuthing suggests that grep is stuck in some kind of infinite loop:

$ echo hello | grep -i --color=always -e ^ | hexdump -C | head -3
00000000  1b 5b 30 31 3b 33 31 6d  1b 5b 30 30 6d 1b 5b 30  |.[01;31m.[00m.[0|
00000010  31 3b 33 31 6d 1b 5b 30  30 6d 1b 5b 30 31 3b 33  |1;31m.[00m.[01;3|
00000020  31 6d 1b 5b 30 30 6d 1b  5b 30 31 3b 33 31 6d 1b  |1m.[00m.[01;31m.|

$ grep -V | head -1
grep (GNU grep) 2.5.1

I was wondering if folks here could confirm this behaviour on their
boxes, especially on non-Ubuntu 7.10 installs.  Here it is in script
form:

$ true && (
echo hello | grep --color=always -e ^ | hexdump -C | head -1
echo hello | grep -i --color=always -e ^ | hexdump -C | head -1
)

If I run the above I get this output:

00000000  68 65 6c 6c 6f 0a                                 |hello.|
00000000  1b 5b 30 31 3b 33 31 6d  1b 5b 30 30 6d 1b 5b 30  |.[01;31m.[00m.[0|

I would imagine that on non-affected systems one would get two lines
with "hello".

Thanks in advance for your help.

Regards,
- Robert



More information about the mdlug mailing list