bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep bug


From: Bob Proulx
Subject: Re: grep bug
Date: Sun, 23 Oct 2005 10:53:47 -0600
User-agent: Mutt/1.5.9i

Ronny Melz wrote:
> I have noticed a bug in the grep tool, grep (GNU grep) 2.5.1, gentoo 
> kernel 2.6.11, which is simply reproducable by:
> 
> echo foo | grep [A-F]
> 
> and has been verified to occur on a different gentoo box of a friend of 
> mine. Whenever a set of capital letters is specified by using the dash, 
> the set matches lower case letters just as well.

Thanks for your report.  It is much appreciated.  However what you are
seeing is not a bug in grep.  What you are seeing is normal behavior
when a dictionary collating sequence is set in your locale setting.
This is a very common issue due to systems setting this without your
knowledge.  This affects all programs such as sort and ls and not just
grep.  You can check your locale settings with the locale command.

  locale

With the LANG variable set to a dictionary sort order locale such as
en_US in my case (or guessing en_DE in your case) the collating
sequence is set to AaBbCcDdEe...YyZz instead of the POSIX standard
order A-Za-z.  This means that A-F matches [AaBbCcDdEeF] in the
character class pattern of your example.

If this is in a script then it is probably best to set LC_ALL=C or
POSIX to get standard behavior.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]