More windows quoting trouble

58 views
Skip to first unread message

Ben Fritz

unread,
Sep 14, 2013, 3:38:14 PM9/14/13
to vim...@googlegroups.com
Try searching with :grep for a string containing a quote (as in http://superuser.com/questions/645157/vim-how-do-you-use-external-grep-to-search-for-quotation-marks)

Either the grep command given in that post, or the following:

:!findstr \"foo test.txt

For some reason, it appears that "findstr" consumes the " so unlike any other command in Windows '\' is the escape character.

This search doesn't work with shellxquote set to either ( or "(. In both cases the shell returns 1 for no results.

It works with shellxquote set to ", or set to empty.

The corresponding :grep \" test.txt only seems to work with shellxquote set to ".

Anyway, some experimentation in the cmd.exe shell shows that "( ought to work, but for some reason the " isn't being escaped according to shellxescape:

C:\Users\Ben\AppData\Local\Temp>cmd /c "(findstr \^"jkl test.txt)"
"jkl

:!findstr \"jkl test.txt
C:\Windows\system32\cmd.exe /c "(findstr \"jkl test.txt)"
shell returned 1

Regardless, I can't figure out how we could get the default value of ( to work:
C:\Users\Ben\AppData\Local\Temp>cmd /c (findstr \^"jkl test.txt)

C:\Users\Ben\AppData\Local\Temp>cmd /c (findstr \"jkl test.txt)

C:\Users\Ben\AppData\Local\Temp>cmd /c (findstr \^^"jkl test.txt)
"jkl


Is there a reason why " isn't escaped when shellxquote is "(? If it were escaped with ^, then the search should work.

Also I don't recall, why isn't "( the default?

Reply all
Reply to author
Forward
0 new messages