From 3243f7a08272a5f973a92fec781589e98f9f47b7 Mon Sep 17 00:00:00 2001 From: "Brandon L. Reiss" Date: Wed, 27 Jan 2021 13:12:17 -0500 Subject: [PATCH] [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`. --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index 8d57cae..e0eccfe 100644 --- a/nvm.sh +++ b/nvm.sh @@ -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