From d59ac0394aa30753ab4c4350a9c43b3fda14bbb5 Mon Sep 17 00:00:00 2001 From: Eli Young Date: Tue, 3 Mar 2015 14:30:28 -0800 Subject: [PATCH] Don't use --color if grep doesn't support it Not all versions of grep support the --color flag. This checks the output of grep --help when building the grep command and avoids using flags that aren't compatible with the version present. Fixes #234. --- autoload/gitgutter/diff.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/autoload/gitgutter/diff.vim b/autoload/gitgutter/diff.vim index af5ed8b..2524c20 100644 --- a/autoload/gitgutter/diff.vim +++ b/autoload/gitgutter/diff.vim @@ -1,5 +1,12 @@ let s:grep_available = executable('grep') -let s:grep_command = ' | '.(g:gitgutter_escape_grep ? '\grep' : 'grep').' --color=never -e '.gitgutter#utility#shellescape('^@@ ') +if s:grep_available + let s:grep_command = ' | '.(g:gitgutter_escape_grep ? '\grep' : 'grep') + let s:grep_help = gitgutter#utility#system('grep --help') + if s:grep_help =~# '--color' + let s:grep_command .= ' --color=never' + endif + let s:grep_command .= ' -e '.gitgutter#utility#shellescape('^@@ ') +endif let s:hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@'