Skip to content

Commit

Permalink
[Fix] Fix potential unbound var error on nvm install
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
blr246 authored and ljharb committed Jan 27, 2021
1 parent 015623e commit 3243f7a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3243f7a

Please sign in to comment.