>Number:         166842
>Category:       bin
>Synopsis:       bsdgrep inconsistently handles ^ in non-anchoring positions
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 11 13:50:12 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Jim Pryor
>Release:        9.0-PRELEASE
>Organization:
>Environment:
FreeBSD vaio.jimpryor.net 9.0-PRERELEASE FreeBSD 9.0-PRERELEASE #0: Tue Nov 29 
02:45:33 EST 2011     [email protected]:/usr/obj/usr/src/sys/MINE  amd64
>Description:
version line:
/*      $FreeBSD: src/usr.bin/grep/grep.c,v 1.11.2.3 2011/10/20 16:08:11 gabor 
Exp $

According to the POSIX-2008 standard, "^" and "$" should be ordinary characters 
in BREs (basic regexs) when they're not in anchoring positions (as contrasted 
to EREs, where they should always be anchors). Hence:

$ printf 'a^b$c' | grep -o 'a^b'

should match, and it does when I use Gnu grep (on Linux), and using BusyBox 
grep (again on Linux, built against uClibc). But it doesn't using the described 
version of FreeBSD grep. Curiously though:

$ printf 'a^b$c' | grep -o '[a]^b'

will match. And so too will 'b$c'.

One can't portably rely on '\^' here to specify the literal '^', because 
POSIX-2008 says that '^' in non-anchoring positions is not special in BREs, and 
that the combination of '\' and a non-special character is undefined. Of 
course, neither can one use '[^]'.

>How-To-Repeat:
See above.
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to