diff --git a/libexec/rbenv-version-name b/libexec/rbenv-version-name index cd1d18f..46e3ae7 100755 --- a/libexec/rbenv-version-name +++ b/libexec/rbenv-version-name @@ -13,10 +13,18 @@ if [ -z "$RBENV_VERSION" ] || [ "$RBENV_VERSION" = "system" ]; then exit fi -RBENV_VERSION_PATH="${RBENV_ROOT}/versions/${RBENV_VERSION}" +version_exists() { + local version="$1" + [ -d "${RBENV_ROOT}/versions/${version}" ] +} -if [ -d "$RBENV_VERSION_PATH" ]; then +if version_exists "$RBENV_VERSION"; then echo "$RBENV_VERSION" +elif version_exists "${RBENV_VERSION#ruby-}"; then + { echo "rbenv: ignoring extraneous \`ruby-' prefix in version \`${RBENV_VERSION}'" + echo "(set by $(rbenv-version-origin))" + } >&2 + echo "${RBENV_VERSION#ruby-}" else echo "rbenv: version \`$RBENV_VERSION' is not installed" >&2 exit 1 diff --git a/libexec/rbenv-versions b/libexec/rbenv-versions index 5bfa72e..ea28e5c 100755 --- a/libexec/rbenv-versions +++ b/libexec/rbenv-versions @@ -21,7 +21,7 @@ fi print_version() { if [ "$1" == "$current_version" ]; then - echo "${hit_prefix}$(rbenv-version)" + echo "${hit_prefix}$(rbenv-version 2>/dev/null)" else echo "${miss_prefix}$1" fi