[Toybox] grep -vo

Rob Landley rob at landley.net
Wed Jul 20 00:10:37 PDT 2016


So grep --color requires surprisingly intrusive changes, and while I'm
ripping that a new one I noticed some small bugs (context lines don't
output -b data, and should), and then there's -o -v.

Ubuntu's grep doesn't implement -ov (it outputs nothing when you select
those together), but if you do "toybox grep -ov toybox README" in the
toybox source you get plenty of output... but I'm not happy with it.

In -o -v mode I'm outputting all the line segments that DIDN'T match,
but I'm splitting lines where a match was removed. That's the logical
inverse of the -o behavior, which gives each matching line segment on
its own line, but it seems like -ov is more USEFUL if it just removes
the matching data, which implies "ooh, it should be able to REPLACE it
with something", and then there's the "sed already has a thing for this".

But then grep is basically sed -n '/pattern/p' anyway, isn't it?

Dunno the right thing to do here, thought I'd ask on the list. Posix is,
as usual, no help whatsoever. Neither is LSB.

Should I split the lines or not split the lines?

Rob


More information about the Toybox mailing list