You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
grep: avoid duplicated lines when we're coloring output
For the default uncolored output, we'll just output a line once and then
move on. For colored output, we'll output multiple matches per
line with context from the line interspersed and may end up writing out
some match context multiple times as we don't persist which part of the
lines have already been printed.
Fix it by tracking the length of line printed thus far in printline()
and retaining it across successive calls to printline() in the same
line. printline() should indicate whether it terminated the line or not
to avoid tracking the logic for that in multiple places: -o lines are
always terminated, so it's generally only some --color contexts where we
wouldn't have terminated.
Add a test to make sure that we're only printing one line going forward.
Reported and tested by: Jamie Landeg-Jones <jamie catflap org>
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D49324
0 commit comments