libexec/rbenv-version{,-origin}: move "missing rbenv-version-file detection" logic as per @mislav

This commit is contained in:
Jeffrey 'jf' Lim 2020-01-16 23:15:09 +08:00
parent 40db754168
commit 302797ba41
2 changed files with 7 additions and 8 deletions

View file

@ -8,9 +8,11 @@
set -e set -e
[ -n "$RBENV_DEBUG" ] && set -x [ -n "$RBENV_DEBUG" ] && set -x
RBENV_VERSION_ORIGIN="$(rbenv-version-origin)" version_name="$(rbenv-version-name)"
if [ -z "$RBENV_VERSION_ORIGIN" ]; then version_origin="$(rbenv-version-origin)"
echo "$(rbenv-version-name)"
if [ "$version_origin" = "${RBENV_ROOT}/version" ] && [ ! -e "$version_origin" ]; then
echo "$version_name"
else else
echo "$(rbenv-version-name) (set by $RBENV_VERSION_ORIGIN)" echo "$version_name (set by $version_origin)"
fi fi

View file

@ -17,8 +17,5 @@ if [ -n "$RBENV_VERSION_ORIGIN" ]; then
elif [ -n "$RBENV_VERSION" ]; then elif [ -n "$RBENV_VERSION" ]; then
echo "RBENV_VERSION environment variable" echo "RBENV_VERSION environment variable"
else else
RBENV_VERSION_FILE="$(rbenv-version-file)" rbenv-version-file
if [ -e "$RBENV_VERSION_FILE" ]; then
echo $RBENV_VERSION_FILE
fi
fi fi