Page MenuHomeFreeBSD

bsdgrep(1): Remove output separators between overlapping segments in context (-A/B/C) output
ClosedPublic

Authored by kevans on Mar 22 2017, 9:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 9, 6:52 PM
Unknown Object (File)
Thu, May 9, 6:51 PM
Unknown Object (File)
Thu, May 9, 6:51 PM
Unknown Object (File)
Thu, May 9, 7:50 AM
Unknown Object (File)
Tue, Apr 16, 5:07 AM
Unknown Object (File)
Mar 16 2024, 7:35 PM
Unknown Object (File)
Mar 13 2024, 11:44 PM
Unknown Object (File)
Dec 20 2023, 1:05 AM
Subscribers

Details

Summary

Make bsdgrep(1) more sensitive to context overlaps -- if it's printing context that either overlaps or is immediately adjacent to another bit of context, don't print a separator.

This combined with D10101 allows bsdgrep(1) to pass the remaining context tests in the Kyua tests.

Test Plan

Run kyua tests to make sure no additional regressions have occured.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Do you have some before/after examples? Are these behaviors codified in tests?

In D10105#213548, @cem wrote:

Do you have some before/after examples? Are these behaviors codified in tests?

I do not have specific examples off hand, but this is codified in both the context and context2 tests. context2 requires both this and the -z flag to actually pass, though. I can whip up examples later tonight if requested.

I'm a fan of Cram for testing this kind of CLI program output, but I don't suppose we have that, even in ports.

In D10105#213549, @kevans91_ksu.edu wrote:

I do not have specific examples off hand, but this is codified in both the context and context2 tests. context2 requires both this and the -z flag to actually pass, though. I can whip up examples later tonight if requested.

Yes, please :-).

It would be good to have tests for all of the new behavior(s), too (if context/context2 don't cover it all).

In D10105#213551, @cem wrote:

Yes, please :-).

Alright, so, given this input file:

a
b
c
d
e
f

Current behavior:

$ egrep -C 1 'b|d' test_file
a
b
c
--
--
c
d
e
$ egrep -C 1 'b|e' test_file
a
b
c
--
--
d
e
f

New behavior:

$ egrep -C 1 'b|d' test_file
a
b
c
d
e
$ egrep -C 1 'b|e' test_file
a
b
c
--
d
e
f

Tthings to note:

  • Non-overlapping segments no longer have two separators between them
  • Overlapping segments no longer have separators between them with overlapping sections repeated -- I personally really appreciate this part, given that it's a slightly stronger assertion about the input file, making it more obvious that the context overlaps without -n

It would be good to have tests for all of the new behavior(s), too (if context/context2 don't cover it all).

context and context2 do indeed over all of this and D10101. D10108 grew test cases since you last accepted it for the new grep -r behavior from that review as well as rgrep matching the equivalent grep -r in behavior, so those four test cases total should cover all of the newer behaviors.

This revision is now accepted and ready to land.Apr 8 2017, 1:57 AM
This revision was automatically updated to reflect the committed changes.