From 512e2999ed7ff367580e0d6bc4d2daa81663221f Mon Sep 17 00:00:00 2001 From: acelya Date: Fri, 11 Dec 2020 15:55:12 +0100 Subject: [PATCH] Force cmd.exe to be used by system() instead of pwsh or powershell on Windows --- autoload/gitgutter/utility.vim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/autoload/gitgutter/utility.vim b/autoload/gitgutter/utility.vim index 4a02c2f..ebfcb3a 100644 --- a/autoload/gitgutter/utility.vim +++ b/autoload/gitgutter/utility.vim @@ -176,15 +176,20 @@ endfunction function! s:use_known_shell() abort if has('unix') && &shell !=# 'sh' - let [s:shell, s:shellcmdflag, s:shellredir] = [&shell, &shellcmdflag, &shellredir] + let [s:shell, s:shellcmdflag, s:shellredir, s:shellpipe, s:shellquote, s:shellxquote] = [&shell, &shellcmdflag, &shellredir, &shellpipe, &shellquote, &shellxquote] let &shell = 'sh' set shellcmdflag=-c shellredir=>%s\ 2>&1 endif + if has('win32') && (&shell ==# 'pwsh' || &shell ==# 'powershell') + let [s:shell, s:shellcmdflag, s:shellredir, s:shellpipe, s:shellquote, s:shellxquote] = [&shell, &shellcmdflag, &shellredir, &shellpipe, &shellquote, &shellxquote] + let &shell = 'cmd.exe' + set shellcmdflag=/s\ /c shellredir=>%s\ 2>&1 shellpipe=>%s\ 2>&1 shellquote= shellxquote=" + endif endfunction function! s:restore_shell() abort - if has('unix') && exists('s:shell') - let [&shell, &shellcmdflag, &shellredir] = [s:shell, s:shellcmdflag, s:shellredir] + if (has('unix') || has('win32')) && exists('s:shell') + let [&shell, &shellcmdflag, &shellredir, &shellpipe, &shellquote, &shellxquote] = [s:shell, s:shellcmdflag, s:shellredir, s:shellpipe, s:shellquote, s:shellxquote] endif endfunction