Fix bare `nvm use` when `nvm_ls_current` is "none".

master
Jordan Harband 2015-03-03 11:29:15 -08:00
parent ceb66d1356
commit 8ae7a37d43
1 changed files with 8 additions and 5 deletions

13
nvm.sh
View File

@ -1303,17 +1303,20 @@ nvm() {
return 127 return 127
fi fi
local PROVIDED_VERSION
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
nvm_rc_version nvm_rc_version
if [ -n "$NVM_RC_VERSION" ]; then if [ -n "$NVM_RC_VERSION" ]; then
VERSION="$(nvm_version "$NVM_RC_VERSION")" PROVIDED_VERSION="$NVM_RC_VERSION"
VERSION="$(nvm_version "$PROVIDED_VERSION")"
fi fi
else else
local NVM_IOJS_PREFIX local NVM_IOJS_PREFIX
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
local NVM_NODE_PREFIX local NVM_NODE_PREFIX
NVM_NODE_PREFIX="$(nvm_node_prefix)" NVM_NODE_PREFIX="$(nvm_node_prefix)"
case "_$2" in PROVIDED_VERSION="$2"
case "_$PROVIDED_VERSION" in
"_$NVM_IOJS_PREFIX" | "_io.js") "_$NVM_IOJS_PREFIX" | "_io.js")
VERSION="$(nvm_version $NVM_IOJS_PREFIX)" VERSION="$(nvm_version $NVM_IOJS_PREFIX)"
;; ;;
@ -1321,7 +1324,7 @@ nvm() {
VERSION="system" VERSION="system"
;; ;;
*) *)
VERSION="$(nvm_version "$2")" VERSION="$(nvm_version "$PROVIDED_VERSION")"
;; ;;
esac esac
fi fi
@ -1343,11 +1346,11 @@ nvm() {
return 127 return 127
fi fi
elif [ "_$VERSION" = "_∞" ]; then elif [ "_$VERSION" = "_∞" ]; then
echo "The alias \"$2\" leads to an infinite loop. Aborting." >&2 echo "The alias \"$PROVIDED_VERSION\" leads to an infinite loop. Aborting." >&2
return 8 return 8
fi fi
nvm_ensure_version_installed "$2" nvm_ensure_version_installed "$PROVIDED_VERSION"
EXIT_CODE=$? EXIT_CODE=$?
if [ "$EXIT_CODE" != "0" ]; then if [ "$EXIT_CODE" != "0" ]; then
return $EXIT_CODE return $EXIT_CODE