Is this a regex bug?

Mark Blackman mark at exonetric.com
Sun Jan 26 21:18:42 UTC 2014



On 26 Jan 2014, at 21:04, rank1seeker at gmail.com wrote:

> Or am I crazy?
> 
> echo '-m' | egrep '^\-[[:alnum:]]+$'
> echo '-n' | egrep '^\-[[:alnum:]]+$'
> echo '-o' | egrep '^\-[[:alnum:]]+$'
> 
> Guess what?
> Only middle one, '-n' doesn't match it.
> Is this an RE bug or I clearly ain't seeing obvious?!
> 
> echo '-n' | egrep '^\-[0-9A-Za-z]+$'
>    Doesn't work either
> 
> 9.2-RELEASE-p3  i386

-n is being interpreted as an option to ‘echo’ and being swallowed before it gets to egrep.

- Mark


More information about the freebsd-hackers mailing list