[Toybox] [Patch] - adding '-B' to grep

David Seikel onefang at gmail.com
Mon Dec 23 19:18:46 PST 2013


On Mon, 23 Dec 2013 21:07:38 -0600 Rob Landley <rob at landley.net> wrote:

> On 12/06/13 11:42, ibid.ag at gmail.com wrote:
> > On Fri, Dec 06, 2013 at 06:44:36PM +0530, Ashwini Sharma wrote:
> >> Hi Rob, list,
> >>
> >> _-B_ option support for printing leading context lines, before the
> >> match, is added to grep command.
> 
> There are actually three related options: -A, -B, and -C. After,
> Before, and Context (both). If we're going to do one, might as well
> do all three.
> 
> > I suppose this is something you use, rather than a feature you
> > noticed was not present?
> 
> Almost certainly.
> 
> >> The implementation is based on the queue. Used sys/queue for the
> >> purpose.
> >
> > Please not that way. Would you mind doing it by way of llist/dlist?
> 
> I note that patch does something really similar to this. Maintaining 
> these kind of line buffers is something we've got code and there
> might be some opportunities for code sharing. I'll have to look...

This is why I wanted to include sed as one of the various editors I
wanted to support in my generic editor code.  Less, grep, sed, vi,
emacs, etc. all need to deal with line buffers.  s/foo/bar/g works in
most of the editors, including sed.  Lots and lots of common code
there.  Still on my TODO list to cut it down into easier to digest
bits for you, which is like your TODO, it runneth over, several times.

-- 
A big old stinking pile of genius that no one wants
coz there are too many silver coated monkeys in the world.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20131224/91ff168c/attachment-0002.sig>


More information about the Toybox mailing list