why doesn't rg -F "$finish"
(double quotes) show the same results as rg -F '$finish'
(single quotes)?
#2697
-
Please tick this box to confirm you have reviewed the above.
What version of ripgrep are you using?Using v13.0.0. How did you install ripgrep?linux-musl What operating system are you using ripgrep on?CentOS 7.6, zsh 5.0.2 Describe your bug.Varying behaviour when searching a string with '$' character in it. Searching I saw a few similar issues reported for windows but didn't see it for linux. What are the steps to reproduce the behavior?
What is the actual behavior?Searching with Searching with What is the expected behavior?ripgrep should return 2 matches when using double quotes as well. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
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 -
|
Beta Was this translation helpful? Give feedback.
-
Thank you for the answers. I agree with not putting quotes for the simple searches. I had used them just in case if I wanted to extend my search to mutliple words. |
Beta Was this translation helpful? Give feedback.
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 -