ff6ca9b85643e13ae23b9f47d86eb34dcc5ed576

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #3538 from TheLinuxKitten/grep-if-color

Test if --color=auto is a valid option for grep

Diff

 1diff --git a/lib/grep.zsh b/lib/grep.zsh
 2index 348ebe62316d8e3865949dcf01fd8906bd6c467b..3fa103d19a5827f021742f442aaf3c1148d980a5 100644
 3--- a/lib/grep.zsh
 4+++ b/lib/grep.zsh
 5@@ -3,8 +3,12 @@ grep-flag-available() {
 6     echo | grep $1 "" >/dev/null 2>&1
 7 }
 8 
 9+GREP_OPTIONS=""
10+
11 # color grep results
12-GREP_OPTIONS="--color=auto"
13+if grep-flag-available --color=auto; then
14+    GREP_OPTIONS+=" --color=auto"
15+fi
16 
17 # ignore VCS folders (if the necessary grep flags are available)
18 VCS_FOLDERS="{.bzr,.cvs,.git,.hg,.svn}"