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

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

Re: grep -o ignores locale setting


From: Ronny Melz
Subject: Re: grep -o ignores locale setting
Date: Fri, 28 Oct 2005 20:09:29 +0200
User-agent: Mozilla Thunderbird 1.0.7 (X11/20051015)


Thanks once again, Bob!

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]