Add Vim version constraint to new PowerShell support

Closes https://github.com/tpope/vim-fugitive/issues/1807
This commit is contained in:
Tim Pope
2021-08-05 16:29:06 -04:00
parent 7a087725ee
commit 1da2c02421

View File

@@ -1645,11 +1645,12 @@ function! s:TempCmd(out, cmd) abort
try try
let cmd = (type(a:cmd) == type([]) ? fugitive#Prepare(a:cmd) : a:cmd) let cmd = (type(a:cmd) == type([]) ? fugitive#Prepare(a:cmd) : a:cmd)
let redir = ' > ' . a:out let redir = ' > ' . a:out
if s:winshell() && !has('nvim') let pwsh = &shell =~? '\%(powershell\|pwsh\)\%(\.exe\)\=$'
if pwsh && has('patch-8.2.3079')
return s:SystemError(&shell . ' ' . &shellcmdflag . ' ' . s:shellesc(cmd . redir))
elseif (s:winshell() || pwsh) && !has('nvim')
let cmd_escape_char = &shellxquote == '(' ? '^' : '^^^' let cmd_escape_char = &shellxquote == '(' ? '^' : '^^^'
return s:SystemError('cmd /c "' . s:gsub(cmd, '[<>%]', cmd_escape_char . '&') . redir . '"') return s:SystemError('cmd /c "' . s:gsub(cmd, '[<>%]', cmd_escape_char . '&') . redir . '"')
elseif &shell =~? '\%(powershell\|pwsh\)\%(\.exe\)\=$'
return s:SystemError(&shell . ' ' . &shellcmdflag . ' ' . s:shellesc(cmd . redir))
elseif &shell =~# 'fish' elseif &shell =~# 'fish'
return s:SystemError(' begin;' . cmd . redir . ';end ') return s:SystemError(' begin;' . cmd . redir . ';end ')
else else