1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-14 06:13:53 -05:00

Avoid rbenv-exec calling out to rbenv-version-name twice

Running any shim (and thus `rbenv-exec`) would always execute
`rbenv-version-name` twice: once in `rbenv-exec` and another time in
`rbenv-which`, even though RBENV_VERSION variable would have already
been populated at this point.

Now RBENV_VERSION is respected within `rbenv-which`.
This commit is contained in:
Mislav Marohnić
2014-10-13 03:11:12 +02:00
parent 51bd975820
commit 6bb7f07d2d
2 changed files with 14 additions and 1 deletions

View File

@@ -48,7 +48,6 @@ remove_from_path() {
echo "${result%:}"
}
RBENV_VERSION="$(rbenv-version-name)"
RBENV_COMMAND="$1"
if [ -z "$RBENV_COMMAND" ]; then
@@ -56,6 +55,8 @@ if [ -z "$RBENV_COMMAND" ]; then
exit 1
fi
RBENV_VERSION="${RBENV_VERSION:-$(rbenv-version-name)}"
if [ "$RBENV_VERSION" = "system" ]; then
PATH="$(remove_from_path "${RBENV_ROOT}/shims")"
RBENV_COMMAND_PATH="$(command -v "$RBENV_COMMAND" || true)"
@@ -72,6 +73,9 @@ done
if [ -x "$RBENV_COMMAND_PATH" ]; then
echo "$RBENV_COMMAND_PATH"
elif ! [ -d "${RBENV_ROOT}/versions/${RBENV_VERSION}" ]; then
echo "rbenv: version \`$RBENV_VERSION' is not installed" >&2
exit 1
else
echo "rbenv: $RBENV_COMMAND: command not found" >&2