Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Apr 2012 19:30:15 GMT
From:      Jim Pryor <dubiousjim@gmail.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/166842: bsdgrep(1) inconsistently handles ^ in non-anchoring positions
Message-ID:  <201204111930.q3BJUFgv081178@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/166842; it has been noted by GNATS.

From: Jim Pryor <dubiousjim@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/166842: bsdgrep(1) inconsistently handles ^ in non-anchoring
 positions
Date: Wed, 11 Apr 2012 15:21:01 -0400

 I've noticed some more issues with the same version of grep. I don't
 know whether they're related, but I'll append them here for now.
 
 $ printf abc | grep -o '^[a-c]'
 
 should just print 'a', but instead gives three hits, against each letter
 of the incoming text. The same issue occurs when handling multiline
 buffers:
 
 $ printf 'abc\ndef' | grep -o --null '^[a-f]'
 
 incorrectly matches 6 times.
 
 $ printf 'abc\ndef' | grep -o --null '[a-f]$'
 
 correctly only matches 'c' and 'f'.
 
 
 $ printf 'abc\ndef' | grep -o --null '\`[a-f]'
 
 has the same issue as ^, whereas:
 
 $ printf 'abc\ndef' | grep -o --null '[a-f]\'\'
 
 matches 'c' and 'f'. To fix \` in a way that matches the behavior of \',
 it should only match the 'a' and 'd'. In fact, though, both of these
 should only match against a single character: 'a' for \` and 'f' for \'.
 That's the specified behavior of these Gnu extensions, and how they
 behave in the Gnu grep and BusyBox grep implementations I'm testing
 against. If that behavior isn't going to be provided, then wouldn't it'd
 be better for these extensions not even pretend to be present? And so,
 just match against a literal ` or '?
 -- 
 dubiousjim@gmail.com
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204111930.q3BJUFgv081178>