Merge pull request #605 from dhcmrlchtdj/fix_which

Fix which command in zsh (#604).
master
Jordan Harband 2015-01-01 22:28:30 -08:00
commit 67e8939311
2 changed files with 4 additions and 4 deletions

4
nvm.sh
View File

@ -272,7 +272,7 @@ nvm_alias() {
nvm_ls_current() { nvm_ls_current() {
local NVM_LS_CURRENT_NODE_PATH local NVM_LS_CURRENT_NODE_PATH
NVM_LS_CURRENT_NODE_PATH="$(which node 2> /dev/null)" NVM_LS_CURRENT_NODE_PATH="$(command which node 2> /dev/null)"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo 'none' echo 'none'
elif nvm_tree_contains_path "$NVM_DIR" "$NVM_LS_CURRENT_NODE_PATH"; then elif nvm_tree_contains_path "$NVM_DIR" "$NVM_LS_CURRENT_NODE_PATH"; then
@ -984,7 +984,7 @@ nvm() {
if [ "_$VERSION" = '_system' ]; then if [ "_$VERSION" = '_system' ]; then
if nvm_has_system_node >/dev/null 2>&1; then if nvm_has_system_node >/dev/null 2>&1; then
local NVM_BIN local NVM_BIN
NVM_BIN="$(nvm use system >/dev/null 2>&1 && which node)" NVM_BIN="$(nvm use system >/dev/null 2>&1 && command which node)"
if [ -n "$NVM_BIN" ]; then if [ -n "$NVM_BIN" ]; then
echo "$NVM_BIN" echo "$NVM_BIN"
return return

View File

@ -12,8 +12,8 @@ TEST_PWD=$(pwd)
TEST_DIR="$TEST_PWD/nvm_ls_current_tmp" TEST_DIR="$TEST_PWD/nvm_ls_current_tmp"
rm -rf "$TEST_DIR" rm -rf "$TEST_DIR"
mkdir "$TEST_DIR" mkdir "$TEST_DIR"
ln -s "$(which which)" "$TEST_DIR/which" ln -s "$(command which which)" "$TEST_DIR/which"
ln -s "$(which dirname)" "$TEST_DIR/dirname" ln -s "$(command which dirname)" "$TEST_DIR/dirname"
[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "none" ] || die 'when node not installed, nvm_ls_current did not return "none"' [ "$(PATH="$TEST_DIR" nvm_ls_current)" = "none" ] || die 'when node not installed, nvm_ls_current did not return "none"'
[ "@$(PATH="$TEST_DIR" nvm_ls_current 2> /dev/stdout 1> /dev/null)@" = "@@" ] || die 'when node not installed, nvm_ls_current returned error output' [ "@$(PATH="$TEST_DIR" nvm_ls_current 2> /dev/stdout 1> /dev/null)@" = "@@" ] || die 'when node not installed, nvm_ls_current returned error output'