Delete batchfile only if it exists (#901)

Close #900
This commit is contained in:
Jan Edmund Lazo 2019-11-03 21:10:37 -05:00 committed by GitHub
parent eee50c55bf
commit 68fef9c2fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -822,6 +822,7 @@ function! s:chsh(swap)
endfunction
function! s:bang(cmd, ...)
let batchfile = ''
try
let [sh, shellcmdflag, shrd] = s:chsh(a:0)
" FIXME: Escaping is incomplete. We could use shellescape with eval,
@ -835,7 +836,7 @@ function! s:bang(cmd, ...)
finally
unlet g:_plug_bang
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
if s:is_win
if s:is_win && filereadable(batchfile)
call delete(batchfile)
endif
endtry
@ -2047,6 +2048,7 @@ function! s:with_cd(cmd, dir, ...)
endfunction
function! s:system(cmd, ...)
let batchfile = ''
try
let [sh, shellcmdflag, shrd] = s:chsh(1)
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
@ -2056,7 +2058,7 @@ function! s:system(cmd, ...)
return system(cmd)
finally
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
if s:is_win
if s:is_win && filereadable(batchfile)
call delete(batchfile)
endif
endtry
@ -2379,6 +2381,7 @@ function! s:preview_commit()
wincmd P
endif
setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
let batchfile = ''
try
let [sh, shellcmdflag, shrd] = s:chsh(1)
let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
@ -2388,7 +2391,7 @@ function! s:preview_commit()
execute 'silent %!' cmd
finally
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
if s:is_win
if s:is_win && filereadable(batchfile)
call delete(batchfile)
endif
endtry