Skip to content

why doesn't rg -F "$finish" (double quotes) show the same results as rg -F '$finish' (single quotes)? #2697

Closed Answered by s-p-turner
abhijithcd asked this question in Q&A
Discussion options

You must be logged in to vote

This looks like expected behaviour to me. I don't believe your issue is anything to do with ripgrep. The dollar sign is a special character which Linux uses to specify an environment variable. Putting the dollar sign in double quotes (or no quotes) causes the Linux shell interpreter to substitute the name of the environment variable with its value. Specifying \$ stops the shell from doing the substitution, and the literal $ character is passed instead. Putting the dollar sign in single quotes stops the shell interpreter from doing this environment variable detection.

So -

  1. '$finish' - passes the literal string $finish.
  2. '\$finish' - passes the literal string \$finish.
  3. "$finish" - passes th…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@BurntSushi
Comment options

Answer selected by BurntSushi
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
3 participants
Converted from issue

This discussion was converted from issue #2696 on January 02, 2024 17:28.