-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
leading forward slash needs to be escaped for unknown reason #1277
Comments
In DOS/Windows forward slash always was a start of command parameter, e.g. Not sure if it’s related to the question… |
Yes, that's may be the reason. Although ripgrep on windows accepts "-" as option specifiers, too, so perhaps it should not accept / it's hard to say. It appears that all the powershell stuff now uses the dash format inplace of the slashes. The thing is too, that an argument of "/exchangecommshub" generates no error, and you get no results, so it's not at all obvous that you get no results for that reason. |
Thanks for the bug report! This does indeed sound strange. It "smells" like a shell issue on Windows, but there isn't enough data for this bug report to be actionable unfortunately. My guess is that you're using cygwin, which will (I think) automatically do path translation on arguments. I've requested more details below: Your link is broken. I get a 404: https://redacted.com/redacted/redacted/v1/004022555784/exchangecommshub Please provide some input that can be searched that reproduces your problem. Please also show the actual output of the command that you ran. Please also show the equivalent grep commands and its output. Please also state which shell on Windows you're using and confirm that you're using the same shell for both ripgrep and grep. |
I think I have identified the problem. The problem exists when running rg in a msys2 shell. And it appears that becuase rg.exe is installed ourside of the msys installation, it converts paths by adding a prefix. First, The package was installed via cargo install ripgrep in a windows shell. (cargo install ripgrep) msys2 shell
The process command line here was: Windows Shell
The procces command line here was: rg works correctly in the Windows subsystem shell, thereforce it appears to be the msys shell remapping mechanism that is causing the problem. |
Please show the output of |
In particular, there should be a line in the trace output that contains |
Msys2 shell: Windows (CMD) shell |
Yeah, you can see that when you run in the MSYS shell, that the actual regex that ripgrep searches is As far as I'm concerned, this is just crazy behavior from MSYS in assuming that any argument given to a command line program is a file path, and I don't see any reasonable way for ripgrep to fix this. It is interesting to me that grep doesn't exhibit the same behavior, but your version of grep is likely bundled with MSYS in a way that makes it play nice with this automatic path translation behavior. I don't see an easy way for ripgrep to play along here. Unfortunate, but this is a |
I agree. I can see why msys does this, so that it can correctly mapp it's view of the current directory for external programs. msys guessing that the parameter is a path from a leading slash is dubious, but perhaps there isn't another solution, if there is one I may propose a change to msys. I used [/] at the begining of the regex to get around this problem. |
I just ran across this issue, and just want to add Git for Windows's explanation and workarounds on this (https://github.com/git-for-windows/build-extra/blob/main/ReleaseNotes.md#known-issues):
|
What version of ripgrep are you using?
C:\opt\bin>rg --version
ripgrep 11.0.1
-SIMD -AVX (compiled)
+SIMD -AVX (runtime)
How did you install ripgrep?
cargo install ripgrep
What operating system are you using ripgrep on?
Microsoft Windows [Version 10.0.17134.590]
Describe your question, feature request, or bug.
executing rg "/exchangecommshub"
against any files where a url component is /exchangecommshub does not match for reasons unknown. I assume ripgrep things its a path? This is in contrast to grep, and is surprising.
The leading path separator must be "escaped":
rg "[/]exchangecommshub"
If this is a bug, what are the steps to reproduce the behavior?
Corpus line:
https://redacted.com/redacted/redacted/v1/004022555784/exchangecommshub
Rg:
rg "/exchangecommshub"
If this is a bug, what is the actual behavior?
If this is a bug, what is the expected behavior?
It should have found all files and lines within which contain the literal "/exchangecommshub" in the same way that grep behaves, or it should say why it is/will surprisingly differ from the grep output
The text was updated successfully, but these errors were encountered: