From a0124f066af13dbdeba77f56b3ed910ff5f5df92 Mon Sep 17 00:00:00 2001 From: gmarik Date: Sat, 23 Jul 2011 17:27:53 -0500 Subject: [PATCH] use Vim's lcd to change directories - and get rid of shell equivalents - profit: portable code (no MSwin specific stuff) --- autoload/vundle/installer.vim | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index a226092..8966a63 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -69,14 +69,11 @@ endf func! s:sync(bang, bundle) abort let git_dir = expand(a:bundle.path().'/.git/') + if isdirectory(git_dir) if !(a:bang) | return [0, 'skip'] | endif - let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull' - - if (has('win32') || has('win64')) - let cmd = substitute(cmd, '^cd ','cd /d ','') " add /d switch to change drives - let cmd = '"'.cmd.'"' " enclose in quotes - endif + lcd `=a:bundle.path()` + let cmd = 'git pull' else let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path()) endif @@ -87,6 +84,7 @@ func! s:sync(bang, bundle) abort echohl Error | echo 'Error installing "'.a:bundle.name.'". Failed cmd: '.cmd | echohl None return [v:shell_error, 'error'] end + return [0, 'ok'] endf @@ -94,7 +92,13 @@ func! s:install(bang, bundles) abort let [installed, errors] = [[],[]] for b in a:bundles - let [err_code, status] = s:sync(a:bang, b) + let cwd = getcwd() + try + let [err_code, status] = s:sync(a:bang, b) + finally + lcd `=cwd` + endtry + if 0 == err_code if 'ok' == status | call add(installed, b) | endif else