Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Apr 2012 11:37:04 -0400
From:      Jim Pryor <dubiousjim@gmail.com>
To:        "John D. Hendrickson and Sara Darnell" <johnandsara2@cox.net>
Cc:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/166842: bsdgrep(1) inconsistently handles ^ in non-anchoring positions
Message-ID:  <1334245024.11829.140661061535169.6EEC2FD8@webmail.messagingengine.com>
In-Reply-To: <4F86F142.2010401@cox.net>
References:  <201204120410.q3C4ACqg071289@freefall.freebsd.org> <4F86F142.2010401@cox.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Apr 12, 2012, at 11:14 AM, John D. Hendrickson and Sara Darnell
wrote:
> Your problem is incorrect so there is no sol'n.
> 
> 	printf 'abc def' | grep -o '^[a-z]'
> 
> is only supposed to match against abc.
> 
> see grep(1) about pattern matching - there is plenty of online writeups,
> esp posix ieee std.  see 
> also "ant / antlr" for more about patterns and matching.
> 
> Jim Pryor wrote:
> > The following reply was made to PR bin/166842; it has been noted by GNATS.
> > From: Jim Pryor <dubiousjim@gmail.com>
> >  $ printf 'abc def' | grep -o '^[a-z]'
> >  will match against each of the letters in 'abc', but not against any of
> >  the letters in 'def'.
> >  dubiousjim@gmail.com


Hi John, I'm sorry I didn't describe the problem adequately to prevent
this misunderstanding.
$ printf 'abc def' | grep -o '^[a-z]'
Expected output: a
That is in fact the output I get from Gnu grep.
Actual output on FreeBSD:
a
b
c

The matches against "b" and "c" are incorrect.

-- 
dubiousjim@gmail.com




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