From bf529e7d63733c4fcaaedc70ab3cdd51c7288766 Mon Sep 17 00:00:00 2001 From: Dylan Markow Date: Thu, 9 Feb 2012 15:33:32 -0800 Subject: [PATCH] Simplify alternate search for rbenv executable. Rather than iterating over the entire $PATH, just try `which rbenv` similar to the Bundler plugin. --- plugins/rbenv/rbenv.plugin.zsh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh index 57c5dde39..3d2834c20 100644 --- a/plugins/rbenv/rbenv.plugin.zsh +++ b/plugins/rbenv/rbenv.plugin.zsh @@ -8,15 +8,12 @@ for rbenvdir in "$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" ; do done unset rbenvdir -# If not found above, check the rest of $PATH for an rbenv executable (usually installed -# in /usr/local/bin, but may be installed elsewhere) +# If not found above, check for the existence of the rbenv executable anyway. if [ $FOUND_RBENV -eq 0 ] ; then - for dir in ${path} ; do - if [ -x $dir/rbenv ] ; then - FOUND_RBENV=1 - break - fi - done + if ( which rbenv > /dev/null 2>&1 ) ; then + FOUND_RBENV=1 + export RBENV_ROOT=$(rbenv root) + fi fi if [ $FOUND_RBENV -eq 1 ] ; then