-
Notifications
You must be signed in to change notification settings - Fork 140
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
Fix -w behaviour and docs (<https://github.com/petdance/ack2/issues/445>) #558
Conversation
Thanks for the patch. Something of this magnitude needs some severe test coverage before I can even think of merging it in. |
I will add some tests. |
I'm also concerned about any potential speed degradations. The change you're suggesting here needs to be discussed on the ack-users mailing list because it is potentially a huge breakage of existing behavior. The new -w may be "fixed", but it is changing existing behavior and we have to be very very very careful with that. |
Would you prefer that I first document and test the existing behaviour, and then we can decide whether to change it? |
I think that makes a lot of sense. If anything is going to be changed, then there will have to be a clear explanation of that change in the Changes file for any future users. |
I've sent a pull request which documents and tests the current semantics. |
I've posted on ack-user asking about this proposed change to -w semantics. |
There haven't been any comments on ack-users. What is your opinion on the proposed change? |
I've only skimmed it. First thing that comes to mind is that we can't change anything related to parentheses until we get the highlighting bug fixed. |
I don't think this is really 'related to parentheses'; the parens are just one example test case that demonstrates the bug (where -w fails to require a whole word match). Here is another test case:
This should match a two-letter whole word, but it ends up matching all three strings. Or indeed
should match the whole words 'ox' and 'ax', but finds the not-whole-word match inside 'box' too. |
Do you have time for a closer look at the fix? As I mentioned it is not related to parentheses or any other particular regexp feature; it fixes the problem that if the given regexp doesn't begin with a word character then the -w flag fails to work. #14 is an older bug covering the same issues. Contributor hoelzro reviewed an earlier version of the patch in #445 |
@petdance What are your thoughts on this moving forward? No one on ack-users seems to mind that this would change. |
How does grep handle this? If you Test cases to consider:
|
|
As far as I know grep handles it correctly, in that the -w causes it to match whole words (and doesn't depend on whether the regexp given begins or ends with a word character).
|
@epa: We need to stick to facts and not use words like "correct" or "wrong", because that's an opinion, and everyone has an opinion on things but they can get confusing. |
I do agree, which is why I clarified exactly what I meant by 'correct' in this case. |
Somewhat related: https://rt.perl.org/Public/Bug/Display.html?id=127670 |
The behavior of |
No description provided.