Merge pull request #2166 from cap10morgan/no-clobber-rbenv-root

rbenv plugin: don't clobber existing RBENV_ROOT & follow Homebrew's default behavior
This commit is contained in:
Robby Russell 2014-03-08 08:13:19 -08:00
commit 92a54ebc7e
1 changed files with 7 additions and 1 deletions

View File

@ -10,12 +10,18 @@ FOUND_RBENV=0
rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv") rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv")
if _homebrew-installed && _rbenv-from-homebrew-installed ; then if _homebrew-installed && _rbenv-from-homebrew-installed ; then
rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}") rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}")
if [[ $RBENV_ROOT = '' ]]; then
RBENV_ROOT="$HOME/.rbenv"
fi
fi fi
for rbenvdir in "${rbenvdirs[@]}" ; do for rbenvdir in "${rbenvdirs[@]}" ; do
if [ -d $rbenvdir/bin -a $FOUND_RBENV -eq 0 ] ; then if [ -d $rbenvdir/bin -a $FOUND_RBENV -eq 0 ] ; then
FOUND_RBENV=1 FOUND_RBENV=1
export RBENV_ROOT=$rbenvdir if [[ $RBENV_ROOT = '' ]]; then
RBENV_ROOT=$rbenvdir
fi
export RBENV_ROOT
export PATH=${rbenvdir}/bin:$PATH export PATH=${rbenvdir}/bin:$PATH
eval "$(rbenv init --no-rehash - zsh)" eval "$(rbenv init --no-rehash - zsh)"