From 75b2a9a8daf6589f9747ff4f2d068fdea54e92ea Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Sat, 24 Jul 2021 12:28:07 +0100 Subject: [PATCH] Improve PowerShell support with recent Vim References: https://github.com/tpope/vim-fugitive/pull/1783 --- autoload/fugitive.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 02126b8..af324be 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -465,7 +465,7 @@ function! s:BuildEnvPrefix(env) abort let env = items(a:env) if empty(env) return '' - elseif &shellcmdflag =~# '-Command' + elseif &shell =~? '\%(powershell\|pwsh\)\%(\.exe\)\=$' return join(map(env, '"$Env:" . v:val[0] . " = ''" . substitute(v:val[1], "''", "''''", "g") . "''; "'), '') elseif s:winshell() return join(map(env, '"set " . substitute(join(v:val, "="), "[&|<>^]", "^^^&", "g") . "& "'), '') @@ -1607,9 +1607,11 @@ 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() || &shellcmdflag ==# '-Command') && !has('nvim') + if s:winshell() && !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