[Fix] Fix potential unbound var error on nvm install

Fixes #2420. When using `nvm install` with an already installed
version, Bash (and potentially other shells) may emit an unbound
variable error when `set -u` is set. The presence of the error depends
on specific shell versions, but appears to happen in MacOS 11.1 (Big
Sur) using a recent Bash version installed via Homebrew (as of this
writing).

The fix accesses `ALIAS` correctly for the case where it is not set by
an `alias` option to `nvm install`.
Brandon L. Reiss 2021-01-27 13:12:17 -05:00 committed by Jordan Harband
parent 015623ee6d
commit 3243f7a082
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
1 changed files with 1 additions and 1 deletions

2
nvm.sh
View File

@ -3078,7 +3078,7 @@ nvm() {
nvm_ensure_default_set "${provided_version}"
fi
if [ -n "${ALIAS}" ]; then
if [ -n "${ALIAS-}" ]; then
nvm alias "${ALIAS}" "${provided_version}"
fi