From 3b0f68180f37da1a38abfaec72726d81423808a5 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 28 Jul 2019 19:11:03 -0400 Subject: [PATCH] Compensate for bad 'shellredir' --- autoload/fugitive.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 601a8ee..44fa372 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -420,6 +420,14 @@ endfunction function! s:SystemError(cmd, ...) abort try + if &shellredir ==# '>' && &shell =~# 'sh\|cmd' + let shellredir = &shellredir + if &shell =~# 'csh' + set shellredir=>& + else + set shellredir=>%s\ 2>&1 + endif + endif let out = call('system', [type(a:cmd) ==# type([]) ? fugitive#Prepare(a:cmd) : a:cmd] + a:000) return [out, v:shell_error] catch /^Vim\%((\a\+)\)\=:E484:/ @@ -427,6 +435,10 @@ function! s:SystemError(cmd, ...) abort call filter(opts, 'exists("+".v:val) && !empty(eval("&".v:val))') call map(opts, 'v:val."=".eval("&".v:val)') call s:throw('failed to run `' . a:cmd . '` with ' . join(opts, ' ')) + finally + if exists('shellredir') + let &shellpipe = shellredir + endif endtry endfunction