From 302797ba41b9885f7c5efb47339ff78e6da61cca Mon Sep 17 00:00:00 2001 From: Jeffrey 'jf' Lim Date: Thu, 16 Jan 2020 23:15:09 +0800 Subject: [PATCH] libexec/rbenv-version{,-origin}: move "missing rbenv-version-file detection" logic as per @mislav --- libexec/rbenv-version | 10 ++++++---- libexec/rbenv-version-origin | 5 +---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libexec/rbenv-version b/libexec/rbenv-version index f968cd1f..c95ab0d3 100755 --- a/libexec/rbenv-version +++ b/libexec/rbenv-version @@ -8,9 +8,11 @@ set -e [ -n "$RBENV_DEBUG" ] && set -x -RBENV_VERSION_ORIGIN="$(rbenv-version-origin)" -if [ -z "$RBENV_VERSION_ORIGIN" ]; then - echo "$(rbenv-version-name)" +version_name="$(rbenv-version-name)" +version_origin="$(rbenv-version-origin)" + +if [ "$version_origin" = "${RBENV_ROOT}/version" ] && [ ! -e "$version_origin" ]; then + echo "$version_name" else - echo "$(rbenv-version-name) (set by $RBENV_VERSION_ORIGIN)" + echo "$version_name (set by $version_origin)" fi diff --git a/libexec/rbenv-version-origin b/libexec/rbenv-version-origin index 139d8157..3f1d4f03 100755 --- a/libexec/rbenv-version-origin +++ b/libexec/rbenv-version-origin @@ -17,8 +17,5 @@ if [ -n "$RBENV_VERSION_ORIGIN" ]; then elif [ -n "$RBENV_VERSION" ]; then echo "RBENV_VERSION environment variable" else - RBENV_VERSION_FILE="$(rbenv-version-file)" - if [ -e "$RBENV_VERSION_FILE" ]; then - echo $RBENV_VERSION_FILE - fi + rbenv-version-file fi