[PATCH] grep: properly handle grep -w "^str"

Denys Vlasenko vda.linux at googlemail.com
Fri Feb 7 16:16:16 UTC 2014


On Fri, Feb 7, 2014 at 3:26 PM, Bartosz Gołaszewski
<bartekgola at gmail.com> wrote:
> 2014-02-07 Denys Vlasenko <vda.linux at googlemail.com>:
>> On Thu, Feb 6, 2014 at 9:34 PM, Bartosz Golaszewski
>> <bartekgola at gmail.com> wrote:
>>> Pass the REG_NOTBOL flag to subsequent regexec calls.
>>
>> Which use case it fixes?
>> I would like to add it to testsuite.
>
> It's already there:
>
> testing "grep -w ^str doesn't match str not at the beginning" \
>         "grep -w ^str input" \
>         "" \
>         "strstr\n" \
>         ""
>
> and
>
> commit cd55f2d9332489432ba2b3093903949c6c2e3e33
> Author: Denys Vlasenko <vda.linux at googlemail.com>
> Date:   Tue Jan 7 14:57:42 2014 +0100
>
>     grep: fix two bugs with -w
>
>     Unfortunately, with +!EXTRA_COMPAT, "grep -w ^str" still
> erroneously matches "strstr".

A closely related case is still broken:

echo 'komkom' | busybox grep -w kom

This should not match... I'm fixing it too.

Try current git.


More information about the busybox mailing list