Просмотр исходного кода

Fix #159 by temporarily setting &shell to sh

Junegunn Choi 11 лет назад
Родитель
Сommit
79da5b2654
2 измененных файлов с 31 добавлено и 6 удалено
  1. 14 6
      plug.vim
  2. 17 0
      test/regressions.vader

+ 14 - 6
plug.vim

@@ -777,7 +777,7 @@ function! s:job_abort()
   for [name, j] in items(s:jobs)
     silent! call jobstop(j.jobid)
     if j.new
-      call system('rm -rf ' . s:shellesc(g:plugs[name].dir))
+      call s:system('rm -rf ' . s:shellesc(g:plugs[name].dir))
     endif
   endfor
   let s:jobs = {}
@@ -1191,8 +1191,16 @@ function! s:with_cd(cmd, dir)
 endfunction
 
 function! s:system(cmd, ...)
-  let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
-  return system(s:is_win ? '('.cmd.')' : cmd)
+  try
+    let sh = &shell
+    if !s:is_win
+      set shell=sh
+    endif
+    let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
+    return system(s:is_win ? '('.cmd.')' : cmd)
+  finally
+    let &shell = sh
+  endtry
 endfunction
 
 function! s:system_chomp(...)
@@ -1280,7 +1288,7 @@ function! s:clean(force)
     if yes
       for dir in todo
         if isdirectory(dir)
-          call system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(dir))
+          call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(dir))
         endif
       endfor
       call append(line('$'), 'Removed.')
@@ -1297,7 +1305,7 @@ function! s:upgrade()
   redraw
   try
     if executable('curl')
-      let output = system(printf('curl -fLo %s %s', s:shellesc(new), s:plug_src))
+      let output = s:system(printf('curl -fLo %s %s', s:shellesc(new), s:plug_src))
       if v:shell_error
         throw get(s:lines(output), -1, v:shell_error)
       endif
@@ -1535,7 +1543,7 @@ function! s:snapshot(...) abort
   if a:0 > 0
     let fn = s:esc(expand(a:1))
     call writefile(getline(1, '$'), fn)
-    if !s:is_win | call system('chmod +x ' . fn) | endif
+    if !s:is_win | call s:system('chmod +x ' . fn) | endif
     echo 'Saved to '.a:1
     silent execute 'e' fn
   endif

+ 17 - 0
test/regressions.vader

@@ -201,3 +201,20 @@ Execute (#145: Merging on-demand loading triggers - map):
   Assert empty(mapcheck("<Plug>(xxx)"))
   Assert empty(mapcheck("<Plug>(yyy)"))
 
+**********************************************************************
+Execute (#159: shell=/bin/tcsh):
+  let org = &shell
+  try
+    set shell=/bin/tcsh
+    call plug#begin('$TMPDIR/plugged')
+    Plug 'junegunn/seoul256.vim'
+    call plug#end()
+
+    PlugStatus
+    Log getline(1, '$')
+    q
+    AssertEqual '/bin/tcsh', &shell
+  finally
+    let &shell = org
+  endtry
+