Skip to content

Commit 68fef9c

Browse files
authored
Delete batchfile only if it exists (#901)
Close #900
1 parent eee50c5 commit 68fef9c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

plug.vim

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ function! s:chsh(swap)
822822
endfunction
823823

824824
function! s:bang(cmd, ...)
825+
let batchfile = ''
825826
try
826827
let [sh, shellcmdflag, shrd] = s:chsh(a:0)
827828
" FIXME: Escaping is incomplete. We could use shellescape with eval,
@@ -835,7 +836,7 @@ function! s:bang(cmd, ...)
835836
finally
836837
unlet g:_plug_bang
837838
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
838-
if s:is_win
839+
if s:is_win && filereadable(batchfile)
839840
call delete(batchfile)
840841
endif
841842
endtry
@@ -2047,6 +2048,7 @@ function! s:with_cd(cmd, dir, ...)
20472048
endfunction
20482049

20492050
function! s:system(cmd, ...)
2051+
let batchfile = ''
20502052
try
20512053
let [sh, shellcmdflag, shrd] = s:chsh(1)
20522054
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
@@ -2056,7 +2058,7 @@ function! s:system(cmd, ...)
20562058
return system(cmd)
20572059
finally
20582060
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
2059-
if s:is_win
2061+
if s:is_win && filereadable(batchfile)
20602062
call delete(batchfile)
20612063
endif
20622064
endtry
@@ -2379,6 +2381,7 @@ function! s:preview_commit()
23792381
wincmd P
23802382
endif
23812383
setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
2384+
let batchfile = ''
23822385
try
23832386
let [sh, shellcmdflag, shrd] = s:chsh(1)
23842387
let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
@@ -2388,7 +2391,7 @@ function! s:preview_commit()
23882391
execute 'silent %!' cmd
23892392
finally
23902393
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
2391-
if s:is_win
2394+
if s:is_win && filereadable(batchfile)
23922395
call delete(batchfile)
23932396
endif
23942397
endtry

0 commit comments

Comments
 (0)