vrothberg/vgrep

Support double dash (--) to signify the end of command options

Whissi opened this issue · 3 comments

I want to grep for a string starting with a dash, i.e. -luuid.
When using grep I would invoke grep like grep -Fr -- -luuid. When doing the same with vgrep I'll get the error

searching symbols failed: error: unknown switch `u' [git]
Qeole commented

Note that the double dash is currently supported. But instead of telling grep/ripgrep/git grep to stop considering the rest of the arguments as options, it tells vgrep not to consider them and to pass them down to whatever grep tool it calls. For example:

$ vgrep -- -d foo

Will pass -d to grep instead of calling vgrep in debug mode.

Therefore, if you want to pass a double dash to your grep tool, you can simply “escape” it... With another double dash.

$ vgrep -- -Fr -- -luuid
        ^      ^ grep stops reading options from here
        ^ vgrep passes all to grep from here

@Whissi, does it work for you as suggested by @Qeole ?

Yes, thank you very much. Learned something new ;)