diff --git a/nvm.sh b/nvm.sh index 0b57f05..bee8456 100644 --- a/nvm.sh +++ b/nvm.sh @@ -1141,7 +1141,7 @@ nvm_alias() { return 2 fi - command cat "${NVM_ALIAS_PATH}" + command awk 'NF' "${NVM_ALIAS_PATH}" } nvm_ls_current() { diff --git a/test/fast/Aliases/'nvm alias' should ignore leading blank lines in the file b/test/fast/Aliases/'nvm alias' should ignore leading blank lines in the file new file mode 100755 index 0000000..3fe5784 --- /dev/null +++ b/test/fast/Aliases/'nvm alias' should ignore leading blank lines in the file @@ -0,0 +1,20 @@ +#!/bin/sh + +die() { echo "$@" ; exit 1; } + +export NVM_DIR="$(cd ../../.. && pwd)" + +\. "${NVM_DIR}/nvm.sh" +\. ../../common.sh + +echo " + +v0.0.1 +" > ../../../alias/test-blank-lines + +EXPECTED='v0.0.1' +ACTUAL="$(nvm_alias test-blank-lines)" +EXIT_CODE="$(nvm_alias test-blank-lines 2>&1 >/dev/null; echo $?)" + +[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<" +[ "${EXIT_CODE}" = '0' ] || die "expected exit code 0, got ${EXIT_CODE}" diff --git a/test/fast/Aliases/teardown b/test/fast/Aliases/teardown index 005c729..33e1b02 100755 --- a/test/fast/Aliases/teardown +++ b/test/fast/Aliases/teardown @@ -15,3 +15,4 @@ rm -f "../../../alias/unstable" rm -f "../../../alias/node" rm -f "../../../alias/iojs" rm -f "../../../alias/default" +rm -f "../../../alias/test-blank-lines"