Is this a regex bug?

rank1seeker at gmail.com rank1seeker at gmail.com
Sun Jan 26 21:32:58 UTC 2014


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


I've tried without echo

printf "\-n\n" | egrep '^\-[[:alnum:]]+$'

This works!
Thanks for pointing out.



> Try without the grep:
> 
> $ echo '-m'
> -m
> $ echo '-n'
> $ echo '-o'
> -o
> $ man echo
> 
> 
> 
> 
> On Jan 26, 2014, at 1:04 PM, 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 


More information about the freebsd-hackers mailing list