Avoid slow abs_dirname() by loading realpath extension

This speeds up every `rbenv` invocation significantly.
This commit is contained in:
Mislav Marohnić 2014-01-04 16:36:02 +01:00
parent 284588f9b4
commit 5287e2ebf4

View file

@ -12,6 +12,12 @@ if [ -n "$RBENV_DEBUG" ]; then
set -x set -x
fi 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) READLINK=$(type -p greadlink readlink | head -1)
if [ -z "$READLINK" ]; then if [ -z "$READLINK" ]; then
echo "rbenv: cannot find readlink - are you missing GNU coreutils?" >&2 echo "rbenv: cannot find readlink - are you missing GNU coreutils?" >&2
@ -35,6 +41,7 @@ abs_dirname() {
pwd pwd
cd "$cwd" cd "$cwd"
} }
fi
if [ -z "${RBENV_ROOT}" ]; then if [ -z "${RBENV_ROOT}" ]; then
RBENV_ROOT="${HOME}/.rbenv" RBENV_ROOT="${HOME}/.rbenv"