f2130fa1a3f440418a6c48f9bace43ce7443117f

Author
The Linux Kitten <kitten@openbsdbox>
Committer
The Linux Kitten <kitten@openbsdbox>
Date

Message

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}"