Skip to content

Commit

Permalink
Only use GREP_OPTIONS when it's not deprecated
Browse files Browse the repository at this point in the history
Moddern versions of grep print:

> grep: warning: GREP_OPTIONS is deprecated; please use an alias or script

When GREP_OPTIONS is in use, so we'll only set it when it's allowed.

TODO: this might need some more testing
  • Loading branch information
mattfoster committed Apr 26, 2015
1 parent 96d1262 commit ff9f7fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 01_path
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ pathdirs=(
/Applications/VMWare\ Fusion.app/Contents/Library
$HOME/Applications/VMWare\ Fusion.app/Content/Library
/Library/Frameworks/Python.framework/Versions/Current/bin
/usr/local/opt/coreutils/libexec/gnubin
/usr/local/bin
/usr/local/git/bin
/usr/local/libexec/git-core
/opt/local/bin
/usr/local/opt/coreutils/libexec/gnubin
$HOME/bin
$HOME/.rbenv/bin
)
Expand Down
8 changes: 6 additions & 2 deletions 05_grep
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ if [[ -x `which ggrep` ]]; then
alias grep='ggrep --color'
fi

output=$(GREP_OPTIONS=test grep --version 2>&1)

if [[ $output == ".*GREP_OPTIONS.*" ]]; then
# From zsh-lovers: detect gnu grep:
(grep --help 2>/dev/null |grep -- --color) >/dev/null && \
export GREP_OPTIONS='--color=auto'
(grep --help 2>/dev/null |grep -- --color) >/dev/null && \
export GREP_OPTIONS='--color=auto'
fi

0 comments on commit ff9f7fc

Please sign in to comment.