Repository navigation
Conversation
The -A, -B and -C handling only worked for a single match: - leading context of a later match was inserted in front of the previous match when there was no trailing context - lines that were already printed were printed again when leading context overlapped them - lines inside trailing context were never tested, so a match there got no context of its own and was not counted by -m - context lines ignored --trim-end Walk the lines once and remember the last printed line, like GNU grep.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
grep -A/-B/-Cworks for a single match but goes wrong with several:-Bwithout-A: the leading context of a later match lands in front of the previous match.ABC,1,2,ABC,3 | grep -B1 ABCgives2,ABC,ABCinstead ofABC,2,ABC.-m.ABC,1,ABC,2,3 | grep -A1 ABCdrops2.--trim-end.The loop now walks the lines once and remembers the last printed line. I checked the expected output in the new tests against GNU grep. Line number prefixes on context lines stay
:as before.