diff --git a/nvm.sh b/nvm.sh index 0a9b586..24ff367 100644 --- a/nvm.sh +++ b/nvm.sh @@ -13,7 +13,8 @@ nvm_has() { } nvm_is_alias() { - command alias "$1" > /dev/null 2>&1 + # this is intentionally not "command alias" so it works in zsh. + \alias "$1" > /dev/null 2>&1 } nvm_get_latest() { diff --git a/test/fast/Unit tests/nvm_is_alias b/test/fast/Unit tests/nvm_is_alias new file mode 100755 index 0000000..b5cf305 --- /dev/null +++ b/test/fast/Unit tests/nvm_is_alias @@ -0,0 +1,20 @@ +#!/bin/sh + +cleanup () { unalias foo; unalias grep; } +die () { echo $@ ; cleanup ; exit 1; } + +. ../../../nvm.sh + +alias foo='bar' +nvm_is_alias foo || die '"nvm_is_alias foo" was not true' + +! nvm_is_alias nvm_is_alias || die '"nvm_is_alias nvm_is_alias was not false' + +alias grep='grep' +unalias grep || die '"unalias grep" failed' +! nvm_is_alias grep || die '"nvm_is_alias grep" with unaliased grep was not false' + +alias grep='grep' +nvm_is_alias grep || die '"nvm_is_alias grep" with aliased grep was not true' + +cleanup