Merge pull request #1669 from mail6543210/master

Fix for $path used by zsh
Jordan Harband 2017-11-22 08:52:13 -08:00 committed by GitHub
commit 7bfd1e0644
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 12 deletions

18
nvm.sh
View File

@ -13,13 +13,7 @@
NVM_SCRIPT_SOURCE="$_"
nvm_echo() {
command printf %s\\n "$*" 2>/dev/null || {
nvm_echo() {
# shellcheck disable=SC1001
\printf %s\\n "$*" # on zsh, `command printf` sometimes fails
}
nvm_echo "$@"
}
command printf %s\\n "$*" 2>/dev/null
}
nvm_cd() {
@ -273,12 +267,12 @@ nvm_tree_contains_path() {
# Traverse up in directory tree to find containing folder
nvm_find_up() {
local path
path="${PWD}"
while [ "${path}" != "" ] && [ ! -f "${path}/${1-}" ]; do
path=${path%/*}
local path_
path_="${PWD}"
while [ "${path_}" != "" ] && [ ! -f "${path_}/${1-}" ]; do
path_=${path_%/*}
done
nvm_echo "${path}"
nvm_echo "${path_}"
}

View File

@ -21,6 +21,7 @@ rm -rf "$TEST_DIR"
mkdir "$TEST_DIR"
ln -s "$(command which which)" "$TEST_DIR/which"
ln -s "$(command which dirname)" "$TEST_DIR/dirname"
ln -s "$(command which printf)" "$TEST_DIR/printf"
[ "$(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'