grep: bug or feature ?

Denys Vlasenko vda.linux at googlemail.com
Sun Mar 1 02:33:11 UTC 2009


On Thursday 19 February 2009 03:45:04 pm walter harms wrote:
> Hi list,
> i was porting a script to an embedded box with bb and found the
> following effect:
> 
> ./busybox grep "[a-Z]" /etc/hosts
> grep: bad regex '[a-Z]': Invalid range end
> 
> while
>  grep "[a-Z]" /etc/hosts
> 
> works with no problem.
> 
> bug or feature ?

Use CONFIG_EXTRA_COMPAT=y. I just tested, with this option
off I am getting "Invalid range end", with it on I dont.

This options makes grep use GNU regex matching.

I bet GNU grep uses GNU regex matching routines, not POSIX.
The differense has to be only on C API level -
GNU regex can match NULs, POSIX cannot.

But apparently in reality the differences run deeper.
--
vda


More information about the busybox mailing list