Check shell in Windows before assuming cmd.exe

In Windows, some users set the Cygwin shell as their Vim shell, make
Vundle consider this when deciding which flavour of commands to run when
cloning. Roughly check if the shell contains `sh` in it, and assume a
Unix shell, even when on Windows.
This commit is contained in:
forethinker 2013-10-27 23:05:48 -07:00 committed by Jacobo de Vera
parent c3ec879694
commit 05fde637a0

View File

@ -169,7 +169,7 @@ endf
func! vundle#installer#delete(bang, dir_name) abort func! vundle#installer#delete(bang, dir_name) abort
let cmd = (has('win32') || has('win64')) ? let cmd = ((has('win32') || has('win64')) && empty(matchstr(&shell, 'sh'))) ?
\ 'rmdir /S /Q' : \ 'rmdir /S /Q' :
\ 'rm -rf' \ 'rm -rf'
@ -251,7 +251,7 @@ func! s:sync(bang, bundle) abort
endf endf
func! g:shellesc(cmd) abort func! g:shellesc(cmd) abort
if (has('win32') || has('win64')) if ((has('win32') || has('win64')) && empty(matchstr(&shell, 'sh')))
if &shellxquote != '(' " workaround for patch #445 if &shellxquote != '(' " workaround for patch #445
return '"'.a:cmd.'"' " enclose in quotes so && joined cmds work return '"'.a:cmd.'"' " enclose in quotes so && joined cmds work
endif endif
@ -260,7 +260,7 @@ func! g:shellesc(cmd) abort
endf endf
func! g:shellesc_cd(cmd) abort func! g:shellesc_cd(cmd) abort
if (has('win32') || has('win64')) if ((has('win32') || has('win64')) && empty(matchstr(&shell, 'sh')))
let cmd = substitute(a:cmd, '^cd ','cd /d ','') " add /d switch to change drives let cmd = substitute(a:cmd, '^cd ','cd /d ','') " add /d switch to change drives
let cmd = g:shellesc(cmd) let cmd = g:shellesc(cmd)
return cmd return cmd