Closed blueyed closed 5 years ago
And escaping e.g.
'+'
is certainly needed.
Is it? In the shell the escaped and unescaped form works for me. When I add +
to the escaped characters, the test line breaks.
Try these:
git grep '\.\.ad\\\\f40+\$'\'':-# @=,!;%\^&&\*()_{}/ /4304\\'\''""?`9\$343%\$ \^adfadf\[ad)\[('
git grep '\.\.ad\\\\f40\+\$'\'':-# @=,!;%\^&&\*()_{}/ /4304\\'\''""?`9\$343%\$ \^adfadf\[ad)\[('
(I got these commands by using the operator on the test line.)
The former matches, the latter does not.
With both your commands I get "unmatched closing parenthesis".
git version 2.23.0
Is this related to --perl-regexp
/ having it built with pcre?
The test line only works for me on this branch (using xmap gs <plug>(GrepperOperator)
, and git
as first/default tool), on master I get the "unmatched closing parenthesis" error:
fatal: command line, '" ..ad\\f40+\$':-# @=,!;%\^&&*()_{}/ /4304\'""?`9\$343%\$ \^adfadf[ad)[(': unmatched closing parenthesis
Hmm, looking at the Homebrew formula (git version --build-options
isn't really useful), my git 2.23.0 is indeed built with PCRE2 support.
Is your git without pcre2 support?
We force the use of sh
, so a different shell + config shouldn't make a difference. To be on the safe side.. :verb Grepper -noprompt -query foo
shows grepper: running ['sh', '-c', 'git grep -nI --column foo']
for you, right?
git grep -P
works, and pcre is installed (as a dep for git).
I see:
grepper: running ['sh', '-c', 'git grep -nI --column foo']
Running: git grep -nI --column foo
But I've also tested this outside of Neovim - does git grep '+'
really work for you?
Ah, I see.. I have grep.patternType = perl
in my Git config.. i.e. git grep -P '+'
would fail for you also then.
Should we force grep.patternType=default
then maybe, to match the escape characters?
I have
grep.patternType = perl
in my Git config
Ah, sneaky!
When grep.patternType = default
, then grep.extendedRegexp
needs to be considered as well.
Let's just force --basic-regexp
by adding -G
to this line instead? Then, people changing g:grepper.git.grepprg
to use something else, need to adjust g:grepper.git.escape
accordingly.
If you agree, feel free to change the PR to using -G
instead.
Amended.
Thanks! ✨
While it appears to be smart about e.g.
'{'
alone, it also handles it in its escaped form. And escaping e.g.'+'
is certainly needed.