top | item 45631217

(no title)

cormacrelf | 4 months 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.

discuss

order

burntsushi|4 months ago

Yeah, that's a good call out. You would need `rg -F -e -pattern`.

account42|4 months ago

The 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|4 months ago

It has since day 1. And you can use the `-e/--regexp` flag too, just like grep.