Use cmd.exe shellescape inside batchfile
This commit is contained in:
parent
226d6abeb2
commit
8754b3ed74
13
plug.vim
13
plug.vim
|
@ -809,7 +809,7 @@ function! s:bang(cmd, ...)
|
||||||
if s:is_win
|
if s:is_win
|
||||||
let batchfile = tempname().'.bat'
|
let batchfile = tempname().'.bat'
|
||||||
call writefile(["@echo off\r", cmd . "\r"], batchfile)
|
call writefile(["@echo off\r", cmd . "\r"], batchfile)
|
||||||
let cmd = s:shellesc(expand(batchfile))
|
let cmd = s:shellesc(expand(batchfile), &shell)
|
||||||
endif
|
endif
|
||||||
let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%')
|
let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%')
|
||||||
execute "normal! :execute g:_plug_bang\<cr>\<cr>"
|
execute "normal! :execute g:_plug_bang\<cr>\<cr>"
|
||||||
|
@ -1208,7 +1208,7 @@ function! s:spawn(name, cmd, opts)
|
||||||
let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd
|
let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd
|
||||||
if !empty(job.batchfile)
|
if !empty(job.batchfile)
|
||||||
call writefile(["@echo off\r", cmd . "\r"], job.batchfile)
|
call writefile(["@echo off\r", cmd . "\r"], job.batchfile)
|
||||||
let cmd = s:shellesc(expand(job.batchfile))
|
let cmd = s:shellesc(expand(job.batchfile), &shell)
|
||||||
endif
|
endif
|
||||||
let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], cmd)
|
let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], cmd)
|
||||||
|
|
||||||
|
@ -1988,8 +1988,9 @@ function! s:shellesc_cmd(arg)
|
||||||
return '^"'.substitute(escaped, '\(\\\+\)$', '\1\1', '').'^"'
|
return '^"'.substitute(escaped, '\(\\\+\)$', '\1\1', '').'^"'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:shellesc(arg)
|
function! s:shellesc(arg, ...)
|
||||||
if &shell =~# 'cmd.exe$'
|
let shell = get(a:000, 0, s:is_win ? 'cmd.exe' : 'sh')
|
||||||
|
if shell =~# 'cmd.exe$'
|
||||||
return s:shellesc_cmd(a:arg)
|
return s:shellesc_cmd(a:arg)
|
||||||
endif
|
endif
|
||||||
return shellescape(a:arg)
|
return shellescape(a:arg)
|
||||||
|
@ -2035,7 +2036,7 @@ function! s:system(cmd, ...)
|
||||||
if s:is_win
|
if s:is_win
|
||||||
let batchfile = tempname().'.bat'
|
let batchfile = tempname().'.bat'
|
||||||
call writefile(["@echo off\r", cmd . "\r"], batchfile)
|
call writefile(["@echo off\r", cmd . "\r"], batchfile)
|
||||||
let cmd = s:shellesc(expand(batchfile))
|
let cmd = s:shellesc(expand(batchfile), &shell)
|
||||||
endif
|
endif
|
||||||
return system(cmd)
|
return system(cmd)
|
||||||
finally
|
finally
|
||||||
|
@ -2369,7 +2370,7 @@ function! s:preview_commit()
|
||||||
if s:is_win
|
if s:is_win
|
||||||
let batchfile = tempname().'.bat'
|
let batchfile = tempname().'.bat'
|
||||||
call writefile(["@echo off\r", cmd . "\r"], batchfile)
|
call writefile(["@echo off\r", cmd . "\r"], batchfile)
|
||||||
let cmd = expand(batchfile)
|
let cmd = s:shellesc(expand(batchfile), &shell)
|
||||||
endif
|
endif
|
||||||
execute 'silent %!' cmd
|
execute 'silent %!' cmd
|
||||||
finally
|
finally
|
||||||
|
|
Loading…
Reference in New Issue
Block a user