grep misses patterns that start with a dash
Author: vitolee-1018Created Sep 28, 2026Updated Sep 28, 2026
What happened
getRgSearchCmd puts the search pattern in the argv right after the flags. Ripgrep treats an argument that starts with - as a flag.
searchWithRipgrep then appends --ignore-file after the path. A bare -- before the pattern would not end the flags, because that later option would be parsed as another path.
Reproduced with ripgrep 14.1.0. rg --json -H -n -0 -needle <dir> --ignore-file <dir>/.gitignore exits 2. The same command with -e -needle exits 0 and returns the match.
getRg returns an empty path while go test is running, so the existing rg tests skip this path.
Expected
A pattern such as -needle is searched as text.
Source: charmbracelet/crush