mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-22 21:02:28 +00: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:
parent
51bd975820
commit
6bb7f07d2d
2 changed files with 14 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -72,3 +72,12 @@ SH
|
|||
assert_success
|
||||
assert_output "HELLO=:hello:ugly:world:again"
|
||||
}
|
||||
|
||||
@test "discovers version from rbenv-version-name" {
|
||||
mkdir -p "$RBENV_ROOT"
|
||||
cat > "${RBENV_ROOT}/version" <<<"1.8"
|
||||
create_executable "1.8" "ruby"
|
||||
|
||||
RBENV_VERSION= run rbenv-which ruby
|
||||
assert_success "${RBENV_ROOT}/versions/1.8/bin/ruby"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue