Skip to content
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

--file with empty file differs in behavior from grep #900

Closed
mqudsi opened this issue Apr 29, 2018 · 5 comments
Closed

--file with empty file differs in behavior from grep #900

mqudsi opened this issue Apr 29, 2018 · 5 comments
Labels
enhancement An enhancement to the functionality of the software.

Comments

@mqudsi
Copy link

mqudsi commented Apr 29, 2018

What version of ripgrep are you using?

0.8.1

What operating system are you using ripgrep on?

Linux/WSL

Describe your question, feature request, or bug.

From man grep:

-f FILE, --file=FILE
Obtain patterns from FILE, one per line. If this option is used multiple times or is combined with the -e (--regexp) option, search for all patterns given. The empty file contains zero patterns, and therefore matches nothing.

rg's behavior here is to treat an empty file as matching everything instead:

touch empty.txt
rg -l -f empty.txt
# prints all files

See also #783

@BurntSushi
Copy link
Owner

I don't understand what your goal is here. ripgrep differs from grep in many ways. Are you asking for better docs? A change in behavior?

@mqudsi
Copy link
Author

mqudsi commented Apr 29, 2018

Sorry, I should have been clearer. I was requesting that the same handling of an empty file passed to -f be used. The logic is that rg may be programmatically invoked against a generated matches.txt, in which case there is value in treating an empty file as not matching anything.

@BurntSushi BurntSushi added the enhancement An enhancement to the functionality of the software. label Apr 29, 2018
@BurntSushi
Copy link
Owner

OK, I agree. I had a chance to review #783 as well, and I agree that ripgrep should probably be consistent with grep here.

@mqudsi
Copy link
Author

mqudsi commented Apr 29, 2018

Thanks, much appreciated!

@mqudsi
Copy link
Author

mqudsi commented Jul 22, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to the functionality of the software.
Projects
None yet
Development

No branches or pull requests

2 participants