[Fix] unset `NVM_RC_VERSION` env var immediately after it’s no longer needed.

Relates to #1399.
Jordan Harband 2017-02-18 00:48:41 -08:00
parent 49e446dac1
commit e7e4a9b3d6
No known key found for this signature in database
GPG Key ID: 64A196AEE0916D55
1 changed files with 7 additions and 0 deletions

7
nvm.sh
View File

@ -2318,11 +2318,13 @@ nvm() {
nvm_rc_version nvm_rc_version
if [ $version_not_provided -eq 1 ]; then if [ $version_not_provided -eq 1 ]; then
if [ -z "$NVM_RC_VERSION" ]; then if [ -z "$NVM_RC_VERSION" ]; then
unset NVM_RC_VERSION
>&2 nvm --help >&2 nvm --help
return 127 return 127
fi fi
fi fi
provided_version="$NVM_RC_VERSION" provided_version="$NVM_RC_VERSION"
unset NVM_RC_VERSION
fi fi
elif [ $# -gt 0 ]; then elif [ $# -gt 0 ]; then
shift shift
@ -2619,6 +2621,7 @@ nvm() {
PROVIDED_VERSION="$NVM_RC_VERSION" PROVIDED_VERSION="$NVM_RC_VERSION"
VERSION="$(nvm_version "$PROVIDED_VERSION")" VERSION="$(nvm_version "$PROVIDED_VERSION")"
fi fi
unset NVM_RC_VERSION
else else
VERSION="$(nvm_match_version "$PROVIDED_VERSION")" VERSION="$(nvm_match_version "$PROVIDED_VERSION")"
fi fi
@ -2743,6 +2746,7 @@ nvm() {
if [ -n "$NVM_RC_VERSION" ]; then if [ -n "$NVM_RC_VERSION" ]; then
VERSION="$(nvm_version "$NVM_RC_VERSION")" ||: VERSION="$(nvm_version "$NVM_RC_VERSION")" ||:
fi fi
unset NVM_RC_VERSION
if [ "${VERSION:-N/A}" = 'N/A' ]; then if [ "${VERSION:-N/A}" = 'N/A' ]; then
>&2 nvm --help >&2 nvm --help
return 127 return 127
@ -2763,6 +2767,7 @@ nvm() {
fi fi
fi fi
VERSION="$(nvm_version "$NVM_RC_VERSION")" ||: VERSION="$(nvm_version "$NVM_RC_VERSION")" ||:
unset NVM_RC_VERSION
else else
shift shift
fi fi
@ -2838,6 +2843,7 @@ nvm() {
nvm_rc_version nvm_rc_version
fi fi
provided_version="$NVM_RC_VERSION" provided_version="$NVM_RC_VERSION"
unset NVM_RC_VERSION
VERSION="$(nvm_version "$provided_version")" ||: VERSION="$(nvm_version "$provided_version")" ||:
else else
shift shift
@ -2953,6 +2959,7 @@ nvm() {
provided_version="${NVM_RC_VERSION}" provided_version="${NVM_RC_VERSION}"
VERSION=$(nvm_version "${NVM_RC_VERSION}") ||: VERSION=$(nvm_version "${NVM_RC_VERSION}") ||:
fi fi
unset NVM_RC_VERSION
elif [ "_${1}" != '_system' ]; then elif [ "_${1}" != '_system' ]; then
VERSION="$(nvm_version "${provided_version}")" ||: VERSION="$(nvm_version "${provided_version}")" ||:
else else