From 5287e2ebf46b8636af653c1c61d4dc0dffd65796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Sat, 4 Jan 2014 16:36:02 +0100 Subject: [PATCH] Avoid slow `abs_dirname()` by loading `realpath` extension This speeds up every `rbenv` invocation significantly. --- libexec/rbenv | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libexec/rbenv b/libexec/rbenv index 2d475857..a458c473 100755 --- a/libexec/rbenv +++ b/libexec/rbenv @@ -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 @@ -35,6 +41,7 @@ abs_dirname() { pwd cd "$cwd" } +fi if [ -z "${RBENV_ROOT}" ]; then RBENV_ROOT="${HOME}/.rbenv"