diff --git a/nvm.sh b/nvm.sh index 0f96c5d..4db7319 100755 --- a/nvm.sh +++ b/nvm.sh @@ -1846,7 +1846,7 @@ nvm() { fi fi - provided_version=$1 + provided_version="$1" if [ -n "$provided_version" ]; then VERSION="$(nvm_version "$provided_version")" if [ "_$VERSION" = "_N/A" ] && ! nvm_is_valid_version "$provided_version"; then @@ -1860,6 +1860,16 @@ nvm() { fi fi + if [ -n "$NVM_RC_VERSION" ]; then + nvm_ensure_version_installed "$NVM_RC_VERSION" + else + nvm_ensure_version_installed "$provided_version" + fi + EXIT_CODE=$? + if [ "$EXIT_CODE" != "0" ]; then + return $EXIT_CODE + fi + local NVM_IOJS if nvm_is_iojs_version "$VERSION"; then NVM_IOJS=true @@ -1876,10 +1886,7 @@ nvm() { ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?) setopt shwordsplit fi - if [ "_$VERSION" = "_N/A" ]; then - echo "$(nvm_ensure_version_prefix "$provided_version") is not installed yet" >&2 - EXIT_CODE=1 - elif [ -z "$ARGS" ]; then + if [ -z "$ARGS" ]; then if [ "$NVM_IOJS" = true ]; then nvm exec "$VERSION" iojs else diff --git "a/test/slow/nvm run/Running \"nvm run 0.x\" should error out sensibly when 0.x is not installed" "b/test/slow/nvm run/Running \"nvm run 0.x\" should error out sensibly when 0.x is not installed" index 744ac81..bde5867 100755 --- "a/test/slow/nvm run/Running \"nvm run 0.x\" should error out sensibly when 0.x is not installed" +++ "b/test/slow/nvm run/Running \"nvm run 0.x\" should error out sensibly when 0.x is not installed" @@ -5,5 +5,5 @@ die () { echo $@ ; exit 1; } . ../../../nvm.sh -[ "$(nvm run 0.2 --version 2>&1)" = "v0.2 is not installed yet" ] || die "\`nvm run\` with an uninstalled node version failed to error out correctly" -[ "$(nvm run iojs-0.2 --version 2>&1)" = "iojs-v0.2 is not installed yet" ] || die "\`nvm run\` with an uninstalled iojs version failed to error out correctly" +[ "$(nvm run 0.2 --version 2>&1)" = 'N/A: version "v0.2" is not yet installed' ] || die "\`nvm run\` with an uninstalled node version failed to error out correctly" +[ "$(nvm run iojs-0.2 --version 2>&1)" = 'N/A: version "iojs-v0.2" is not yet installed' ] || die "\`nvm run\` with an uninstalled iojs version failed to error out correctly"