From dcf9c399cdfaa3c4c9370a82acdd61fefea98cbd Mon Sep 17 00:00:00 2001 From: Claus Reinke Date: Tue, 31 Mar 2015 20:31:31 +0200 Subject: [PATCH] fix system call handling on windows (#575) - ensure that all system calls go via installer.vim (vundle#installer#system, used to be s:system) - escape/wrap complex command sequences - log commands before trying to execute them --- autoload/vundle/installer.vim | 18 ++++++++++++------ autoload/vundle/scripts.vim | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 5dc5852..a62f0a8 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -287,7 +287,7 @@ func! vundle#installer#delete(bang, dir_name) abort let bundle = vundle#config#init_bundle(a:dir_name, {}) let cmd .= ' '.vundle#installer#shellesc(bundle.path()) - let out = s:system(cmd) + let out = vundle#installer#system(cmd) call s:log('') call s:log('Plugin '.a:dir_name) @@ -347,7 +347,7 @@ endf func! s:get_current_origin_url(bundle) abort let cmd = 'cd '.vundle#installer#shellesc(a:bundle.path()).' && git config --get remote.origin.url' let cmd = vundle#installer#shellesc_cd(cmd) - let out = s:strip(s:system(cmd)) + let out = s:strip(vundle#installer#system(cmd)) return out endf @@ -361,7 +361,7 @@ endf func! s:get_current_sha(bundle) let cmd = 'cd '.vundle#installer#shellesc(a:bundle.path()).' && git rev-parse HEAD' let cmd = vundle#installer#shellesc_cd(cmd) - let out = s:system(cmd)[0:15] + let out = vundle#installer#system(cmd)[0:15] return out endf @@ -448,10 +448,10 @@ func! s:sync(bang, bundle) abort return 'todate' endif - let out = s:system(cmd) call s:log('') call s:log('Plugin '.a:bundle.name_spec) call s:log(cmd, '$ ') + let out = vundle#installer#system(cmd) call s:log(out, '> ') if 0 != v:shell_error @@ -512,8 +512,14 @@ endf " cmd -- the command passed to system() (string) " return -- the return value from system() " --------------------------------------------------------------------------- -func! s:system(cmd) abort - return system(a:cmd) +func! vundle#installer#system(cmd) abort + " would this suffice? + " return system('"'.a:cmd.'"') + let slash = &shellslash + set noshellslash + let result = system(shellescape(a:cmd)) + if slash | set shellslash | endif + return result endf diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index 5d56476..a9946a7 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -85,7 +85,7 @@ func! s:create_changelog() abort let cmd = vundle#installer#shellesc_cd(cmd) - let updates = system(cmd) + let updates = vundle#installer#system(cmd) call add(changelog, '') call add(changelog, 'Updated Plugin: '.bundle.name) @@ -239,7 +239,7 @@ func! s:fetch_scripts(to) return 1 endif - call system(cmd) + call vundle#installer#system(cmd) if (0 != v:shell_error) echoerr 'Error fetching scripts!'