From 84aad508f778d89d89d37a38d20210a946cf6fd0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 12 Oct 2015 16:57:45 -0700 Subject: [PATCH] Check `$#` before trying to check `$1`. Avoids failure due to `nounset` bash option. Partially fixes #868. --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index edbc54a..b5206d2 100755 --- a/nvm.sh +++ b/nvm.sh @@ -2235,7 +2235,7 @@ nvm_supports_xz() { } NVM_VERSION="$(nvm_alias default 2>/dev/null || echo)" -if nvm_supports_source_options && [ "_$1" = "_--install" ]; then +if nvm_supports_source_options && [ "$#" -gt 0 ] && [ "_$1" = "_--install" ]; then if [ -n "$NVM_VERSION" ]; then nvm install "$NVM_VERSION" >/dev/null elif nvm_rc_version >/dev/null 2>&1; then