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

"--null" or "--print0" option? #89

Closed
gwerbin opened this issue Sep 25, 2016 · 11 comments
Closed

"--null" or "--print0" option? #89

gwerbin opened this issue Sep 25, 2016 · 11 comments
Labels
enhancement An enhancement to the functionality of the software.

Comments

@gwerbin
Copy link

gwerbin commented Sep 25, 2016

Is there any chance you'd be interested in implementing a feature like Ag's --null option, and Ack's (not to mention find's) --print0 option? If you did, it'd be really easy to make tag work with Ripgrep, not to mention more supportive of machine-parsing in general.

@BurntSushi
Copy link
Owner

BurntSushi commented Sep 25, 2016

grep has this too. Can we write the specification first? Here's my first attempt:

--null
    Whenever a file name is printed, follow it with a NUL byte.
    This includes printing filenames before matches, and when printing
    a list of matching files such as with --count, --files-with-matches
    and --files.

@kaushalmodi
Copy link
Contributor

I would like to have this option too..

For now, my woraround is to do..

rg foo | tr '\n' '\0'

But hopefully internal support of null-separated output makes this faster.

My actual use case is

rg -g '' --files | tr '\n' '\0' >! proj_file_list.txt

@BurntSushi
Copy link
Owner

@kaushalmodi Unrelated: your -g '' is I think completely superfluous.

@gwerbin
Copy link
Author

gwerbin commented Sep 25, 2016

@BurntSushi LGreatTM, that's a more detailed spec than any of the other tools mentioned here. But maybe it should be both --print0 and --null. Ag has them aliased to each other, Ack only supports --print0, and Pt and Git Grep only support --null.

@kaushalmodi
Copy link
Contributor

@BurntSushi

Unrelated: your -g '' is I think completely superfluous.

Thanks for letting me know.. I'll switch to rg --files then.

@gwerbin

There's -0 too. So -0 or --null or --print0.

@BurntSushi
Copy link
Owner

In general, when there's been variation in flag options, I've tried to go with what grep does. I'm not a big fan of lots of aliases for doing the same thing, although I have done it in a few places. For a more niche option like this, I'd rather not increase the number of flags.

@gwerbin
Copy link
Author

gwerbin commented Sep 25, 2016

@BurntSushi good to be consistent. Unfortunately I have absolutely no experience programming in Rust, otherwise I'd just make a PR for proof-of-concept.

@kaushalmodi I avoided -0 because I always thought of that as an input parsing option as per, e.g. xargs.

@BurntSushi BurntSushi added the enhancement An enhancement to the functionality of the software. label Sep 25, 2016
@emlyn
Copy link
Contributor

emlyn commented Sep 26, 2016

Just a nit about the wording of the spec (Whenever a file name is printed, proceed it with a NUL byte). I've not heard "proceed" used in this way before, is it a misspelling of "precede", or does it mean "follow"?

@BurntSushi
Copy link
Owner

@emlyn "to proceed" is "to come after," so yes, "follow" is right. :-)

Looking at the dictionary, it does feel a little non-standard to me. The flavor isn't quite there. "follow" is probably a better word. I fixed the wording. Thanks!

@gwerbin
Copy link
Author

gwerbin commented Sep 26, 2016

@emlyn Good catch. I definitely thought he meant "precede", which in hindsight wouldn't make sense.

@BurntSushi "proceed" is a motion/action verb, meaning either "to continue" or to physically "go forward."

@BurntSushi
Copy link
Owner

All set! Will be in the next release, hopefully tonight.

amsharma91 added a commit to amsharma91/ripgrep that referenced this issue Sep 27, 2016
This flag causes a NUL byte to follow any file path in ripgrep's output.

Closes BurntSushi#89.
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

4 participants