Skip to content

Commit

Permalink
Fix bare nvm use when nvm_ls_current is "none".
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 3, 2015
1 parent ceb66d1 commit 8ae7a37
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1303,25 +1303,28 @@ nvm() {
return 127
fi

local PROVIDED_VERSION
if [ $# -eq 1 ]; then
nvm_rc_version
if [ -n "$NVM_RC_VERSION" ]; then
VERSION="$(nvm_version "$NVM_RC_VERSION")"
PROVIDED_VERSION="$NVM_RC_VERSION"
VERSION="$(nvm_version "$PROVIDED_VERSION")"
fi
else
local NVM_IOJS_PREFIX
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
local NVM_NODE_PREFIX
NVM_NODE_PREFIX="$(nvm_node_prefix)"
case "_$2" in
PROVIDED_VERSION="$2"
case "_$PROVIDED_VERSION" in
"_$NVM_IOJS_PREFIX" | "_io.js")
VERSION="$(nvm_version $NVM_IOJS_PREFIX)"
;;
"_system")
VERSION="system"
;;
*)
VERSION="$(nvm_version "$2")"
VERSION="$(nvm_version "$PROVIDED_VERSION")"
;;
esac
fi
Expand All @@ -1343,11 +1346,11 @@ nvm() {
return 127
fi
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
fi

nvm_ensure_version_installed "$2"
nvm_ensure_version_installed "$PROVIDED_VERSION"
EXIT_CODE=$?
if [ "$EXIT_CODE" != "0" ]; then
return $EXIT_CODE
Expand Down

0 comments on commit 8ae7a37

Please sign in to comment.