Fix shell detection, Fix shellescape on batchfile

&shell could be escaped on because of spaces.
See patch-8.0.1455 and related 8.1.x patches that address this
for $SHELL on Unix and git-bash on Windows.
This commit is contained in:
Jan Edmund Lazo 2019-12-01 18:47:17 -05:00
parent 54b5493eae
commit da128c45fd
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15

View File

@ -369,8 +369,8 @@ if s:is_win
function! s:batchfile(cmd)
let batchfile = tempname().'.bat'
call writefile(s:wrap_cmds(a:cmd), batchfile)
let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 1})
if &shell =~# 'powershell\.exe$'
let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 0})
if &shell =~# 'powershell\.exe'
let cmd = '& ' . cmd
endif
return [batchfile, cmd]
@ -2005,9 +2005,9 @@ function! plug#shellescape(arg, ...)
let opts = a:0 > 0 && type(a:1) == s:TYPE.dict ? a:1 : {}
let shell = get(opts, 'shell', s:is_win ? 'cmd.exe' : 'sh')
let script = get(opts, 'script', 1)
if shell =~# 'cmd\.exe$'
if shell =~# 'cmd\.exe'
return s:shellesc_cmd(a:arg, script)
elseif shell =~# 'powershell\.exe$' || shell =~# 'pwsh$'
elseif shell =~# 'powershell\.exe' || shell =~# 'pwsh$'
return s:shellesc_ps1(a:arg)
endif
return shellescape(a:arg)