Skip to content

Commit 40aec75

Browse files
committed
Fix shell escaping in job strategy on win32
1 parent c327125 commit 40aec75

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

autoload/dispatch/job.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ function! dispatch#job#handle(request) abort
1919
return 0
2020
endif
2121
if exists('*job_start')
22-
let job = job_start(split(&shell) + split(&shellcmdflag) + [a:request.expanded], {
22+
if has('win32')
23+
let cmd = &shell . ' ' . &shellcmdflag . ' ' . dispatch#windows#escape(a:request.expanded)
24+
else
25+
let cmd = split(&shell) + split(&shellcmdflag) + [a:request.expanded]
26+
endif
27+
let job = job_start(cmd, {
2328
\ 'mode': 'raw',
2429
\ 'callback': function('s:output'),
2530
\ 'close_cb': function('s:closed'),

autoload/dispatch/windows.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if exists('g:autoloaded_dispatch_windows')
55
endif
66
let g:autoloaded_dispatch_windows = 1
77

8-
function! s:escape(str) abort
8+
function! dispatch#windows#escape(str) abort
99
if &shellxquote ==# '"'
1010
return '"' . substitute(a:str, '"', '""', 'g') . '"'
1111
else
@@ -31,7 +31,7 @@ function! dispatch#windows#spawn(title, exec, background) abort
3131
let extra = a:background ? ' /min' : ''
3232
silent execute dispatch#bang('start /min cmd.exe /cstart ' .
3333
\ '"' . substitute(a:title, '"', '', 'g') . '"' . extra . ' ' .
34-
\ &shell . ' ' . &shellcmdflag . ' ' . s:escape(a:exec))
34+
\ &shell . ' ' . &shellcmdflag . ' ' . dispatch#windows#escape(a:exec))
3535
return 1
3636
endfunction
3737

0 commit comments

Comments
 (0)