Skip to content

Commit 9659e10

Browse files
committed
fix shell escaping on cmd.exe (#64)
1 parent 76d579d commit 9659e10

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

autoload/clang_format.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ endfunction
156156

157157
function! s:shellescape(str) abort
158158
if s:on_windows && (&shell =~? 'cmd\.exe')
159-
return '^"' . substitute(substitute(substitute(a:str,
160-
\ '[&|<>()^"%]', '^\0', 'g'),
161-
\ '\\\+\ze"', '\=repeat(submatch(0), 2)', 'g'),
162-
\ '\^"', '\\\0', 'g') . '^"'
159+
" Do not use shellescape() on Windows because it surrounds input with
160+
" single quote when 'shellslash' is on. But cmd.exe requires double
161+
" quotes. So we need to escape by ourselves.
162+
return '"' . substitute(a:str, '[&()[\]{}^=;!''+,`~]', '^\0', 'g') . '"'
163163
endif
164164
return shellescape(a:str)
165165
endfunction

0 commit comments

Comments
 (0)