[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
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)
call s:pushd(a:dict)
silent! !clear 2> /dev/null
@ -235,14 +248,7 @@ function! s:execute(dict, command, temps)
endif
execute 'silent !'.command
redraw!
if v:shell_error == 0 || v:shell_error == 1
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
return s:exit_handler(v:shell_error, command) ? s:callback(a:dict, a:temps) : []
endfunction
function! s:execute_tmux(dict, command, temps)
@ -254,11 +260,7 @@ function! s:execute_tmux(dict, command, temps)
call system(command)
redraw!
if v:shell_error == 2
call s:error('Error running ' . command)
return []
endif
return s:callback(a:dict, a:temps)
return s:exit_handler(v:shell_error, command) ? s:callback(a:dict, a:temps) : []
endfunction
function! s:calc_size(max, val, dict)
@ -334,9 +336,7 @@ function! s:execute_term(dict, command, temps)
endif
endif
if a:code == 2
call s:error('Error running ' . s:command)
sleep
if !s:exit_handler(a:code, s:command, 1)
return
endif