[vim] Consistent exit status handling

This commit is contained in:
Junegunn Choi 2015-09-27 16:26:40 +09:00
parent 545370d2b3
commit 862da2c0b1

View File

@ -222,6 +222,19 @@ endfunction
unlet! s:launcher unlet! s:launcher
let s:launcher = function('s:xterm_launcher') let s:launcher = function('s:xterm_launcher')
function! s:exit_handler(code, command, ...)
if a:code == 130
return 0
elseif a:code > 1
call s:error('Error running ' . a:command)
if !empty(a:000)
sleep
endif
return 0
endif
return 1
endfunction
function! s:execute(dict, command, temps) function! s:execute(dict, command, temps)
call s:pushd(a:dict) call s:pushd(a:dict)
silent! !clear 2> /dev/null silent! !clear 2> /dev/null
@ -235,14 +248,7 @@ function! s:execute(dict, command, temps)
endif endif
execute 'silent !'.command execute 'silent !'.command
redraw! redraw!
if v:shell_error == 0 || v:shell_error == 1 return s:exit_handler(v:shell_error, command) ? s:callback(a:dict, a:temps) : []
return s:callback(a:dict, a:temps)
" Do not print error message on exit status 130 (interrupt)
elseif v:shell_error == 130
return []
else
call s:error('Error running ' . command)
endif
endfunction endfunction
function! s:execute_tmux(dict, command, temps) function! s:execute_tmux(dict, command, temps)
@ -254,11 +260,7 @@ function! s:execute_tmux(dict, command, temps)
call system(command) call system(command)
redraw! redraw!
if v:shell_error == 2 return s:exit_handler(v:shell_error, command) ? s:callback(a:dict, a:temps) : []
call s:error('Error running ' . command)
return []
endif
return s:callback(a:dict, a:temps)
endfunction endfunction
function! s:calc_size(max, val, dict) function! s:calc_size(max, val, dict)
@ -334,9 +336,7 @@ function! s:execute_term(dict, command, temps)
endif endif
endif endif
if a:code == 2 if !s:exit_handler(a:code, s:command, 1)
call s:error('Error running ' . s:command)
sleep
return return
endif endif