-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New option: Stop on non-match after a match #1930
New option: Stop on non-match after a match #1930
Conversation
3dcf3e0
to
ee576d3
Compare
Hi @BurntSushi! No particular rush, but just checking you've seen this PR? Let me know if there's any changes you'd like me to make 🙂 |
No, I haven't looked at it yet. Unfortunately, my time is very limited and I tend to do PR reviews in batches in order to minimize context switching. It might be a while. |
@@ -319,6 +319,7 @@ _rg() { | |||
'(-q --quiet)'{-q,--quiet}'[suppress normal output]' | |||
'--regex-size-limit=[specify upper size limit of compiled regex]:regex size (bytes)' | |||
'*'{-u,--unrestricted}'[reduce level of "smart" searching]' | |||
'--stop-on-nonmatch[stop on first non-matching line after a matching one]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this missing the =
sign like the rest of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The =
sign is only used for flags that accept an argument.
Closes #1790
This implements the option suggested in the linked issue. In particular, it adds a
--stop-on-nonmatch
flag that will stop reading a file once a non-matching line is found after a matching one. This is useful if, for example, a sorted file is being searched and the pattern being matched on is at the start of the line (so it is expected all matches will be adjacent).