Skip to content

Commit

Permalink
Don't use --color if grep doesn't support it
Browse files Browse the repository at this point in the history
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 airblade#234.
  • Loading branch information
elyscape authored and airblade committed Mar 4, 2015
1 parent 4a239a7 commit d59ac03
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion autoload/gitgutter/diff.vim
Original file line number Diff line number Diff line change
@@ -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*\) @@'


Expand Down

0 comments on commit d59ac03

Please sign in to comment.