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
--files-without-matches does not work properly #238
Comments
I know it's 2 years later, but this still seems like an issue? The original test case now passes, but here's a minimal repro, it seems to require a trailing newline:
|
@joshma I see this as an issue too. I can reproduce the above and I run into the issue on a separate instance. |
1) Bug fix for issue ggreer#238 where a file (call it test.txt) of contents "foo\n\n" will be invert matched by this command: ag -L foo test.txt 2) If user specifies both -L and -v on command line, that's a conflict. Resolve by suppressing -v . 3) Added test cases for 1 and 2.
Interesting problem. I believe this commit makes -L work as expected. Give it a shot...let me know if it doesn't work as expected. |
@decaff works for me (although obviously no idea if it breaks anything else) :) |
I just ran into this today! Is it possible to cut a new release with this fix sometime soon? |
$ ag --version Not sure if those commits are in my version yet, but I found a problem that breaks my bash script around ag. This used to work:
Now my script deletes all files because when invoked with an explicit file name, ag doesn't print the match anymore.
That used to work (but unfortunately I don't know until what version). ag should still return the file name to confirm there was a match. Edit Should I open a new issue? I posted here because somehow it looks related to this issue to me, but if I'm wrong I'll file a new bug. Edit 2 I see the return code can be used to test if the match was successful, the problem is that ag will exit with code 1 either if there was no match or if the file couldn't be accessed, so it's confusing. |
This is still an issue in git master (
|
What's the status on this one? |
It's still an issue with current master (630125a). The issue seems to be that -L ignores matches on the first line of the file.
|
First off, ag is awesome so thanks everyone who's involved for your work. It makes me surprised that this issue is still open though, as it makes one doubt the results from ag. Is there an ETA for a fix? |
Any updates on this? |
Still valid today. What was reported by @serhalp is still true. |
Still an issue... I spent 30 minutes trying to understand why a file was showing in both $ ag --version
ag version 2.2.0
Features:
+jit +lzma +zlib
$ echo -e "foo\nbar" > file.txt
$ cat file.txt
foo
bar
$ ag --files-with-matches bar file.txt
file.txt
$ ag --files-without-matches bar file.txt
file.txt
$ echo "" >> file.txt
$ cat file.txt
foo
bar
$ ag --files-with-matches bar file.txt
file.txt
$ ag --files-without-matches bar file.txt
# No result Looks like $ grep --version
grep (GNU grep) 3.1
Packaged by Homebrew
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
$ echo -e "foo\nbar" > file.txt
$ cat file.txt
foo
bar
$ grep -l bar file.txt
file.txt
$ grep -L bar file.txt
# No result |
-l and -L should be mutually exclusive, but they are not.
A simple example illustrating the issue:
The text was updated successfully, but these errors were encountered: