Skip to content

Commit

Permalink
[Fix] unset NVM_RC_VERSION env var immediately after it’s no longer…
Browse files Browse the repository at this point in the history
… needed.

Relates to nvm-sh#1399.
  • Loading branch information
ljharb committed Feb 18, 2017
1 parent 36bf44b commit fa84dde
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2318,11 +2318,13 @@ nvm() {
nvm_rc_version
if [ $version_not_provided -eq 1 ]; then
if [ -z "$NVM_RC_VERSION" ]; then
unset NVM_RC_VERSION
>&2 nvm --help
return 127
fi
fi
provided_version="$NVM_RC_VERSION"
unset NVM_RC_VERSION
fi
elif [ $# -gt 0 ]; then
shift
Expand Down Expand Up @@ -2619,6 +2621,7 @@ nvm() {
PROVIDED_VERSION="$NVM_RC_VERSION"
VERSION="$(nvm_version "$PROVIDED_VERSION")"
fi
unset NVM_RC_VERSION
else
VERSION="$(nvm_match_version "$PROVIDED_VERSION")"
fi
Expand Down Expand Up @@ -2743,6 +2746,7 @@ nvm() {
if [ -n "$NVM_RC_VERSION" ]; then
VERSION="$(nvm_version "$NVM_RC_VERSION")" ||:
fi
unset NVM_RC_VERSION
if [ "${VERSION:-N/A}" = 'N/A' ]; then
>&2 nvm --help
return 127
Expand All @@ -2763,6 +2767,7 @@ nvm() {
fi
fi
VERSION="$(nvm_version "$NVM_RC_VERSION")" ||:
unset NVM_RC_VERSION
else
shift
fi
Expand Down Expand Up @@ -2838,6 +2843,7 @@ nvm() {
nvm_rc_version
fi
provided_version="$NVM_RC_VERSION"
unset NVM_RC_VERSION
VERSION="$(nvm_version "$provided_version")" ||:
else
shift
Expand Down Expand Up @@ -2953,6 +2959,7 @@ nvm() {
provided_version="${NVM_RC_VERSION}"
VERSION=$(nvm_version "${NVM_RC_VERSION}") ||:
fi
unset NVM_RC_VERSION
elif [ "_${1}" != '_system' ]; then
VERSION="$(nvm_version "${provided_version}")" ||:
else
Expand Down

0 comments on commit fa84dde

Please sign in to comment.