From 908662e0660decb2d94072a6d14104a62a3735f8 Mon Sep 17 00:00:00 2001 From: Claus Reinke Date: Tue, 31 Mar 2015 20:26:27 +0200 Subject: [PATCH 1/6] sort out plugin name registry handling (#509) - rename s:check_bundle_name to s:register_bundle_name, it has the side-effect of updating the bundle name registry - expand possible return values - re-registering a plugin name for the same bundle is no conflict - don't continue processing plugins if registration fails --- autoload/vundle/config.vim | 33 +++++++++++++++++++-------------- autoload/vundle/installer.vim | 8 +++++--- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index 0e02b112..d50a6f8c 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -7,8 +7,8 @@ " --------------------------------------------------------------------------- func! vundle#config#bundle(arg, ...) let bundle = vundle#config#init_bundle(a:arg, a:000) - if !s:check_bundle_name(bundle) - return + if 'new'!=s:register_bundle_name(bundle) + return {} endif if exists('g:vundle#lazy_load') && g:vundle#lazy_load call add(g:vundle#bundles, bundle) @@ -84,25 +84,30 @@ endf " --------------------------------------------------------------------------- -" Check if the current bundle name has already been used in this running -" instance and show an error to that effect. +" Check if the current bundle name has already been used by another bundle in +" this running instance. If bundle name is unique and valid, register it to +" current bundle, else show an error. " -" bundle -- a bundle object whose name is to be checked -" return -- 0 if the bundle's name has been seen before, 1 otherwise +" bundle -- a bundle object whose name is to be checked/registered +" return -- 'new'|'known'|'collision'|'invalid' " --------------------------------------------------------------------------- -funct! s:check_bundle_name(bundle) +funct! s:register_bundle_name(bundle) if has_key(s:bundle_names, a:bundle.name) - echoerr 'Vundle error: Name collision for Plugin ' . a:bundle.name_spec . - \ '. Plugin ' . s:bundle_names[a:bundle.name] . - \ ' previously used the name "' . a:bundle.name . '"' . - \ '. Skipping Plugin ' . a:bundle.name_spec . '.' - return 0 + if s:bundle_names[a:bundle.name]==a:bundle.name_spec + return 'known' + else + echoerr 'Vundle error: Name collision for Plugin ' . a:bundle.name_spec . + \ '. Plugin ' . s:bundle_names[a:bundle.name] . + \ ' previously used the name "' . a:bundle.name . '"' . + \ '. Skipping Plugin ' . a:bundle.name_spec . '.' + return 'collision' + endif elseif a:bundle.name !~ '\v^[A-Za-z0-9_-]%(\.?[A-Za-z0-9_-])*$' echoerr 'Invalid plugin name: ' . a:bundle.name - return 0 + return 'invalid' endif let s:bundle_names[a:bundle.name] = a:bundle.name_spec - return 1 + return 'new' endf diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 472271a3..5dc58523 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -15,7 +15,7 @@ func! vundle#installer#new(bang, ...) abort let bundles = filter(copy(g:vundle#bundles), 'index(a:000, v:val.name) > -1') " Specific plugins are specified for installation. Install them. else - let bundles = map(copy(a:000), 'vundle#config#bundle(v:val, {})') + let bundles = filter(map(copy(a:000), 'vundle#config#bundle(v:val, {})'),'v:val!={}') endif if empty(bundles) @@ -150,8 +150,10 @@ endf func! vundle#installer#install_and_require(bang, name) abort let result = vundle#installer#install(a:bang, a:name) let b = vundle#config#bundle(a:name, {}) - call vundle#installer#helptags([b]) - call vundle#config#require([b]) + if b!={} + call vundle#installer#helptags([b]) + call vundle#config#require([b]) + endif return result endf From dcf9c399cdfaa3c4c9370a82acdd61fefea98cbd Mon Sep 17 00:00:00 2001 From: Claus Reinke Date: Tue, 31 Mar 2015 20:31:31 +0200 Subject: [PATCH 2/6] 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 5dc58523..a62f0a82 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 5d564760..a9946a76 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!' From 5a79ceb3dde67bd0c636fe6916406bb2b922e4f1 Mon Sep 17 00:00:00 2001 From: Claus Reinke Date: Tue, 31 Mar 2015 22:03:15 +0200 Subject: [PATCH 3/6] limit extra shellescape to windows --- autoload/vundle/installer.vim | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index a62f0a82..458a2eac 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -515,11 +515,15 @@ endf 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 + if has("win32") || has("win64") + let slash = &shellslash + set noshellslash + let result = system(shellescape(a:cmd)) + if slash | set shellslash | endif + return result + else + return system(a:cmd) + endif endf From 29cfcf008f048582e401b962cf4a3e434dd6b5a8 Mon Sep 17 00:00:00 2001 From: Claus Reinke Date: Mon, 6 Apr 2015 22:37:00 +0200 Subject: [PATCH 4/6] simplify system call wrapping for cmd.exe --- autoload/vundle/installer.vim | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 458a2eac..e9e84cdd 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -513,14 +513,10 @@ endf " return -- the return value from system() " --------------------------------------------------------------------------- func! vundle#installer#system(cmd) abort - " would this suffice? - " return system('"'.a:cmd.'"') if has("win32") || has("win64") - let slash = &shellslash - set noshellslash - let result = system(shellescape(a:cmd)) - if slash | set shellslash | endif - return result + " see cmd.exe docs (scroll down to remarks): + " https://technet.microsoft.com/de-de/library/cc771320(v=ws.10).aspx + return system('"'.a:cmd.'"') else return system(a:cmd) endif From 27ed4c8eef7263cdada72cc7e6f74809b4b5d76a Mon Sep 17 00:00:00 2001 From: Claus Reinke Date: Sun, 12 Apr 2015 23:24:23 +0200 Subject: [PATCH 5/6] account for system call patches in vim --- autoload/vundle/installer.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index e9e84cdd..e978bec6 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -516,7 +516,11 @@ func! vundle#installer#system(cmd) abort if has("win32") || has("win64") " see cmd.exe docs (scroll down to remarks): " https://technet.microsoft.com/de-de/library/cc771320(v=ws.10).aspx - return system('"'.a:cmd.'"') + if v:version>703 || (has("patch443") && has("patch445")) + return system(a:cmd) + else + return system('"'.a:cmd.'"') + endif else return system(a:cmd) endif From 8162713ba76830a7e4b942e32e8a12ef60e78aaf Mon Sep 17 00:00:00 2001 From: Claus Reinke Date: Mon, 13 Apr 2015 23:21:49 +0200 Subject: [PATCH 6/6] be more specific about patch system calls - only test for os, vim version and patch level once - on old vims, only wrap system argument for cmd.exe --- autoload/vundle/installer.vim | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index e978bec6..d78c3645 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -512,19 +512,28 @@ endf " cmd -- the command passed to system() (string) " return -- the return value from system() " --------------------------------------------------------------------------- -func! vundle#installer#system(cmd) abort - if has("win32") || has("win64") +if (has("win32") || has("win64")) && + \ (v:version<703 || + \ (v:version==703 && (!has("patch443") || !has("patch445") || !has("patch446"))) ) + + func! vundle#installer#system(cmd) abort " see cmd.exe docs (scroll down to remarks): " https://technet.microsoft.com/de-de/library/cc771320(v=ws.10).aspx - if v:version>703 || (has("patch443") && has("patch445")) - return system(a:cmd) - else + " and vim patches links: https://github.com/airblade/vim-system-escape + if &shell=~"cmd.exe" return system('"'.a:cmd.'"') + else + return system(a:cmd) endif - else + endf + +else + + func! vundle#installer#system(cmd) abort return system(a:cmd) - endif -endf + endf + +endif " ---------------------------------------------------------------------------