Skip to content

Commit

Permalink
Avoid slow abs_dirname() by loading realpath extension
Browse files Browse the repository at this point in the history
This speeds up every `rbenv` invocation significantly.
  • Loading branch information
mislav committed Oct 13, 2014
1 parent 284588f commit 5287e2e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libexec/rbenv
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ if [ -n "$RBENV_DEBUG" ]; then
set -x
fi

if enable -f "${0%/*}"/../libexec/rbenv-realpath.dylib realpath 2>/dev/null; then
abs_dirname() {
local path="$(realpath "$1")"
echo "${path%/*}"
}
else
READLINK=$(type -p greadlink readlink | head -1)
if [ -z "$READLINK" ]; then
echo "rbenv: cannot find readlink - are you missing GNU coreutils?" >&2
Expand All @@ -35,6 +41,7 @@ abs_dirname() {
pwd
cd "$cwd"
}
fi

if [ -z "${RBENV_ROOT}" ]; then
RBENV_ROOT="${HOME}/.rbenv"
Expand Down

0 comments on commit 5287e2e

Please sign in to comment.