Skip to content

Does rg -g='glob' help to overcome "argument list too long" limitations? #2331

Answered by BurntSushi
learnbyexample asked this question in Q&A
Discussion options

You must be logged in to vote

I think the surface level answer is "yes." It's definitely true that -g/--glob at least won't run afoul of the argument list too long problem because the glob is given literally for ripgrep itself to evaluate. But when you do something like rg search *.txt, that glob is evaluated by the shell (on Unix anyway) and expanded into a list of arguments before invoking ripgrep. So in the latter case, ripgrep doesn't even know a glob was used at all.

The other question is whether -g '*.txt' and *.txt are actually equivalent. They are not! Example:

$ tree         
.
├── bar.md
├── foo.txt
└── quux
    ├── bar.md
    └── foo.txt

1 directory, 4 files

$ rg -l wat        
foo.txt
bar.md
quux/foo.txt…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by learnbyexample
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants