From f2130fa1a3f440418a6c48f9bace43ce7443117f Mon Sep 17 00:00:00 2001 From: The Linux Kitten Date: Mon, 2 Feb 2015 20:49:24 +0100 Subject: [PATCH] Test if --color=auto is a valid option for grep --- lib/grep.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/grep.zsh b/lib/grep.zsh index 348ebe62..3fa103d1 100644 --- a/lib/grep.zsh +++ b/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}"