From 1da2c024213364a2546a361821651df8fb3e47ae Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Thu, 5 Aug 2021 16:29:06 -0400 Subject: [PATCH] Add Vim version constraint to new PowerShell support Closes https://github.com/tpope/vim-fugitive/issues/1807 --- autoload/fugitive.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 9816233..fd234b8 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1645,11 +1645,12 @@ function! s:TempCmd(out, cmd) abort try let cmd = (type(a:cmd) == type([]) ? fugitive#Prepare(a:cmd) : a:cmd) 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 == '(' ? '^' : '^^^' 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' return s:SystemError(' begin;' . cmd . redir . ';end ') else