Is this a regex bug?

Dave Ng chump1 at hushmail.com
Thu Jan 30 19:45:30 UTC 2014


Lots of tools you can use -- to signify the end of option parsing
 Sent using Hushmail
On January 26, 2014 at 1:33 PM, rank1seeker at gmail.com wrote:> -n is
being interpreted as an option to ‘echo’ and being swallowed
before it gets to egrep.
> 
> - Mark
I've tried without echo

printf "-nn" | 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 
_______________________________________________
freebsd-hackers at freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to
"freebsd-hackers-unsubscribe at freebsd.org"


More information about the freebsd-hackers mailing list