From 011fca3f02f82e09e5d3d1fb027ddd4da516bfd3 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Mon, 27 Apr 2020 10:38:35 +0100 Subject: [PATCH] Only use '/d' flag for 'cd' in DOS shell Closes #678. --- autoload/gitgutter/utility.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/gitgutter/utility.vim b/autoload/gitgutter/utility.vim index 4151aea..4a02c2f 100644 --- a/autoload/gitgutter/utility.vim +++ b/autoload/gitgutter/utility.vim @@ -162,7 +162,7 @@ endfunction function! gitgutter#utility#cd_cmd(bufnr, cmd) abort - let cd = s:unc_path(a:bufnr) ? 'pushd' : (gitgutter#utility#windows() ? 'cd /d' : 'cd') + let cd = s:unc_path(a:bufnr) ? 'pushd' : (gitgutter#utility#windows() && s:dos_shell() ? 'cd /d' : 'cd') return cd.' '.s:dir(a:bufnr).' && '.a:cmd endfunction @@ -170,6 +170,10 @@ function! s:unc_path(bufnr) return s:abs_path(a:bufnr, 0) =~ '^\\\\' endfunction +function! s:dos_shell() + return &shell == 'cmd.exe' || &shell == 'command.com' +endfunction + function! s:use_known_shell() abort if has('unix') && &shell !=# 'sh' let [s:shell, s:shellcmdflag, s:shellredir] = [&shell, &shellcmdflag, &shellredir]