From 400fe3106199d241ab6844c8fb47d2a372c556e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohnic=CC=81?= Date: Mon, 1 Apr 2013 03:01:37 +0200 Subject: [PATCH] fix exec fails for invalid version --- libexec/rbenv-exec | 3 ++- test/exec.bats | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libexec/rbenv-exec b/libexec/rbenv-exec index 4ccc610c..eb16dc70 100755 --- a/libexec/rbenv-exec +++ b/libexec/rbenv-exec @@ -21,7 +21,7 @@ if [ "$1" = "--complete" ]; then exec rbenv shims --short fi -export RBENV_VERSION="$(rbenv-version-name)" +RBENV_VERSION="$(rbenv-version-name)" RBENV_COMMAND="$1" if [ -z "$RBENV_COMMAND" ]; then @@ -29,6 +29,7 @@ if [ -z "$RBENV_COMMAND" ]; then exit 1 fi +export RBENV_VERSION RBENV_COMMAND_PATH="$(rbenv-which "$RBENV_COMMAND")" RBENV_BIN_PATH="${RBENV_COMMAND_PATH%/*}" diff --git a/test/exec.bats b/test/exec.bats index ecff7c70..1eaef7d7 100644 --- a/test/exec.bats +++ b/test/exec.bats @@ -9,6 +9,12 @@ create_executable() { chmod +x "${bin}/$1" } +@test "fails with invalid version" { + export RBENV_VERSION="2.0" + run rbenv-exec ruby -v + assert_failure "rbenv: version \`2.0' is not installed" +} + @test "supports hook path with spaces" { hook_path="${RBENV_TEST_DIR}/custom stuff/rbenv hooks" mkdir -p "${hook_path}/exec"