Browse Source

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

The Linux Kitten 9 years ago
parent
commit
f2130fa1a3
1 changed files with 5 additions and 1 deletions
  1. 5 1
      lib/grep.zsh

+ 5 - 1
lib/grep.zsh

@@ -3,8 +3,12 @@ grep-flag-available() {
     echo | grep $1 "" >/dev/null 2>&1
 }
 
+GREP_OPTIONS=""
+
 # color grep results
-GREP_OPTIONS="--color=auto"
+if grep-flag-available --color=auto; then
+    GREP_OPTIONS+=" --color=auto"
+fi
 
 # ignore VCS folders (if the necessary grep flags are available)
 VCS_FOLDERS="{.bzr,.cvs,.git,.hg,.svn}"