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

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

grep -o ignores locale setting (was: [Fwd: Re: grep bug])


From: Bob Proulx
Subject: grep -o ignores locale setting (was: [Fwd: Re: grep bug])
Date: Fri, 28 Oct 2005 10:38:01 -0600
User-agent: Mutt/1.5.9i

Ronny Melz wrote:
> I am still curious about the weird behaviour of grep. look at this example:
> $ echo foo | grep [A-Z]

Using brackets without quoting is not safe in the shell.  The shell
will expand them to match files that happen to match that pattern.
You should always quote all characters special to the shell to avoid
the shell expanding them.  I think you got lucky in this case.

> $ echo foo | grep [A-Z]
> foo
> is explained through LC_COLLATE. but why does

Agreed.

> $ echo foo | grep -o [A-Z]
> not explain which character actually matched? For the other 
> combinations, it does:

I seem to recall a fair number of bugs being reported concerning the
grep -o option.  So at a first guess and without a deeper look I would
say all of the problems with -o are bugs in the code.  But I have not
been following the development of that particular feature of the code.

> $ echo Foo | grep -o [A-Z]
> F
> $ echo Foo | grep -o  [AaBbCcDdEeFf]
> F
> $ echo foo | grep -o  [AaBbCcDdEeFf]
> f

Looks like a bug to me.

  $ export LC_ALL=en_US.UTF-8
  $ echo foo | grep '[A-Z]'
  foo
  $ echo foo | grep -o '[A-Z]'
  $

I remember this being discussed in the list already.  I am sure that
if I searched the list I would find previous discussion of it.

Bob




reply via email to

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