From 39497042bcd7c90acd32a9f38b6fbe8eb8e9553c Mon Sep 17 00:00:00 2001 From: Timothy King Date: Fri, 9 Sep 2011 08:18:14 -0400 Subject: [PATCH 1/2] Adds error handling to rbenv-sh-shell --- libexec/rbenv-sh-shell | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libexec/rbenv-sh-shell b/libexec/rbenv-sh-shell index 187ed6ac..f4e11e8e 100755 --- a/libexec/rbenv-sh-shell +++ b/libexec/rbenv-sh-shell @@ -1,2 +1,16 @@ #!/bin/sh -echo "export RBENV_VERSION=$1" + +if [ -z "$1" ]; then + echo "Please specify one of the following Ruby versions to use:" >&2 + echo "" >&2 + echo "$(rbenv-versions)" >&2 + exit 1 +fi + +version=$1 + +if [ -d "$HOME/.rbenv/versions/$version" ]; then + echo "export RBENV_VERSION=$version" +else + echo "rbenv: version \`$version' is not installed" >&2 +fi From 555472210b6c0e1be0d49830bef8f626f04f78b6 Mon Sep 17 00:00:00 2001 From: Timothy King Date: Fri, 9 Sep 2011 08:22:03 -0400 Subject: [PATCH 2/2] Adds sh-shell subcommand to unset RBENV_VERSION --- libexec/rbenv-sh-shell | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libexec/rbenv-sh-shell b/libexec/rbenv-sh-shell index f4e11e8e..a61f33f3 100755 --- a/libexec/rbenv-sh-shell +++ b/libexec/rbenv-sh-shell @@ -12,5 +12,12 @@ version=$1 if [ -d "$HOME/.rbenv/versions/$version" ]; then echo "export RBENV_VERSION=$version" else - echo "rbenv: version \`$version' is not installed" >&2 + case $version in + default|reset) + echo "unset RBENV_VERSION" + ;; + *) + echo "rbenv: version \`$version' is not installed" >&2 + exit 1 + esac fi