Use powershell '&' to run escaped batchfile

This commit is contained in:
Jan Edmund Lazo 2019-08-03 18:23:26 -04:00
parent 35cfe4b16f
commit bb12f7998d

View File

@ -810,6 +810,9 @@ function! s:bang(cmd, ...)
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(batchfile, &shell) let cmd = s:shellesc(batchfile, &shell)
if &shell =~# 'powershell\.exe$'
let cmd = '& ' . cmd
endif
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>"
@ -2036,6 +2039,9 @@ function! s:system(cmd, ...)
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(batchfile, &shell) let cmd = s:shellesc(batchfile, &shell)
if &shell =~# 'powershell\.exe$'
let cmd = '& ' . cmd
endif
endif endif
return system(cmd) return system(cmd)
finally finally
@ -2370,6 +2376,9 @@ function! s:preview_commit()
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(batchfile, &shell) let cmd = s:shellesc(batchfile, &shell)
if &shell =~# 'powershell\.exe$'
let cmd = '& ' . cmd
endif
endif endif
execute 'silent %!' cmd execute 'silent %!' cmd
finally finally