Skip to content

Commit 3243f7a

Browse files
blr246ljharb
authored andcommitted
[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`.
1 parent 015623e commit 3243f7a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: nvm.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3078,7 +3078,7 @@ nvm() {
30783078
nvm_ensure_default_set "${provided_version}"
30793079
fi
30803080

3081-
if [ -n "${ALIAS}" ]; then
3081+
if [ -n "${ALIAS-}" ]; then
30823082
nvm alias "${ALIAS}" "${provided_version}"
30833083
fi
30843084

0 commit comments

Comments
 (0)