3 ms·
How about -F -regexthatlookslikeaflag? Verbatim, that errors out as the command line parsing tries to interpret it as a flag. If you don’t have -F, then you can
by cormacrelf 1y ago
How about -F -regexthatlookslikeaflag? Verbatim, that errors out as the command line parsing tries to interpret it as a flag. If you don’t have -F, then you can escape the leading hyphen with a backslash in a single quoted string: '\-regex…', but then you don’t get fixed string search. And -F '\-regex…' is a fixed string search for “backslash hyphen r e g e x”. The only way is to manually escape the regex and not use -F.
I think maybe a syntax like -F=-regex would work.
- burntsushi 1y agoYeah, that's a good call out. You would need `rg -F -e -pattern`.
- account42 1y agoThe convention is use use -- to denote the end of options in command-line tools - anything after that is parsed as a normal argument even if it starts with a dash. If rg doesn't support that it should.
- burntsushi 1y agoIt has since day 1. And you can use the `-e/--regexp` flag too, just like grep.