bug-grep
[Top][All Lists]
Advanced

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

Re: Bug or feature?


From: Jim Meyering
Subject: Re: Bug or feature?
Date: Thu, 23 Jun 2011 11:54:44 +0200

Eric Blake wrote:
> On 06/22/2011 04:43 PM, Eric Blake wrote:
>> On 06/22/2011 04:25 PM, Eric Cloninger wrote:
>>> # echo " 1 2 3 4" |grep -o "^ [0-9]"
>>>  1
>>>  2
>>>  3
>>>  4
>>>
>>> It would appear that -o chops up the input stream into a new line
>>> every time a match is found.  However, I expect a "^...." grep to
>>> find only one result per line of input, regardless of the return
>>> method (whole line or only-matching).  Bug or feature?
>>
>> Which version of grep?
>>
>> $ echo " 1 2 3 4" | grep -o '^ [0-9]'
>>  1
>> $ grep (GNU grep) 2.8
>>
>> and likewise for 2.9.
>
> Followup - I can reproduce the bug with grep 2.5.1 on RHEL 5, but I
> don't see a NEWS entry that looks like it would explain why it is now
> working.

Nor do I, but it's not surprising.  There was a lot of churn then.
The --only-matching (-o) option was added just prior, in grep-2.5,
which was a big feature-adding release.  grep-2.5.[1-4] were
bug-fixing releases.

Mention of --only-matching and -o in commit logs suggest that at least
these changes are relevant:

  47fa86e2e3dd0a7d4adf8b22b43cfbdc5704ccfe
  331a18737ade4ddc1ca6881cf4b3b792bbad6dbf
  8a025cf81cdf5c3e809c3ecf0656419a2d596796
  143f885e02eb98ab88a1f18e0aa8d069781bc813
  7360777ea99d3294e1dc600ddf6027cd04ebe256
  2c6c0622db9c42483246b66b70dd0c31014a3da0
  adc240087453cffeb9dbc3119ad06286ea269c35



reply via email to

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