-
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
-w does not interact well with metacharacters #445
Comments
See also #14 |
The reason this is difficult is that |
Right, but currently the documentation explicitly says that \b is used, which implies the usual \b semantics of matching word boundaries rather than whitespace boundaries. So I would say that the test with mu. is incorrect, in that it is expecting something different to what the documentation says. Let's fix the documentation and the test suite to be consistent with each other, and then we have some hope of making the code consistent with both... |
Sounds good to me! |
Hi, any update on this? I believe it is still outstanding in 2.14 despite this bug being added to the 2.14 milestone. |
Someone needs to fix the differences between the docs and the tests. If you'd like to do that and submit a pull request, I'm interested. |
Here's a fix which I think makes the behaviour consistent with the test suite, the documentation consistent with the behaviour, and (IMHO) matches the most common user expectations. Sorry, I am still fiddling with my github account so I wasn't able to make a pull request, but it is a patch to one file:
|
Hi, have you had a chance to look at the patch? |
Thanks for reviewing, @hoelzro. I hope the patch can still be applied for 2.16 since it is self-contained and only affects the -w flag. |
This will have to be fixed in ack 3. |
This has been fixed in ack3. This behavior won't change in ack2. |
-w is documented as matching whole words only, and that it works by wrapping the pattern in \b metacharacters. Given this, you would expect two equivalent regexps to give the same behaviour, e.g.
These are exactly equivalent perl5 regular expressions, but they behave differently with -w:
The fix is quite simple: at present the code doesn't add the \b anchor at the start if the regexp doesn't start with a word character, ditto end. That doesn't match the documentation, which says that the regexp is wrapped with \b unconditionally. Patch to make behaviour match docs:
The text was updated successfully, but these errors were encountered: