Skip to content

Commit

Permalink
fix system call handling on windows (VundleVim#575)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Claus Reinke committed Apr 6, 2015
1 parent cfd3b2d commit 7256631
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 12 additions & 6 deletions autoload/vundle/installer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,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)
Expand Down Expand Up @@ -345,7 +345,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

Expand All @@ -359,7 +359,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

Expand Down Expand Up @@ -446,10 +446,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
Expand Down Expand Up @@ -510,8 +510,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
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.'"')
else
return system(a:cmd)
endif
endf


Expand Down
4 changes: 2 additions & 2 deletions autoload/vundle/scripts.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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!'
Expand Down

0 comments on commit 7256631

Please sign in to comment.