Skip to content
Myr

[Fix] `set -u`: Add default empty value for `$NVM_NO_ALIAS`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Adds a default value for NVM_NO_ALIAS so that nvm ls does not error out when run in a bash nounset/-u (no unset vars) environment.

authored by Sehrope Sarkuni · committed by Jordan Harband · parent 45c1b84 · Browse files · 2 files+24 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+24 added−1 removed

  • tests:+23 added−0 removed
  • other:+1 added−1 removed

2 files+24 added−1 removed

added:test/fast/Listing versions/Running "nvm ls" with nounset should not fail.+23 added
1#!/bin/sh23die () { echo "$@" ; exit 1; }45\. ../../../nvm.sh6\. ../../common.sh78make_fake_node v0.12.34 || die 'fake v0.12.34 could not be made'910# Enable no unset variable11set -u1213# Try an alias that does not exist14output=$(nvm ls 99 2>&1 1>/dev/null || true)15test -z "${output}" || die "1: expected empty; got >${output}"1617# Try a version that does not exist18output=$(nvm ls 0.12.00 2>&1 1>/dev/null || true)19test -z "${output}" || die "2: expected empty; got >${output}"2021# Try a version that does exist22output=$(nvm ls 0.12.34 2>&1 1>/dev/null || true)23test -z "${output}" || die "3: expected empty; got >${output}"
modified:nvm.sh+1 added-1 removed
3159 unmodified lines
3160 ;;3161 esac3162 shift3163 done3164 if [ -n "${PATTERN-}" ] && [ -n "${NVM_NO_ALIAS}" ]; then3164 if [ -n "${PATTERN-}" ] && [ -n "${NVM_NO_ALIAS-}" ]; then3165 nvm_err '`--no-alias` is not supported when a pattern is provided.'3166 return 553167 fi3168 local NVM_LS_OUTPUT
485 unmodified lines