diff --git a/nvm.sh b/nvm.sh index 54a25f6..6354034 100644 --- a/nvm.sh +++ b/nvm.sh @@ -571,11 +571,13 @@ nvm() { NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@" ;; "ls" | "list" ) - nvm_print_versions "`nvm_ls $2`" + NVM_LS_OUTPUT=$(nvm_ls "$2") + NVM_LS_EXIT_CODE=$? + nvm_print_versions "$NVM_LS_OUTPUT" if [ $# -eq 1 ]; then nvm alias fi - return + return $NVM_LS_EXIT_CODE && $? ;; "ls-remote" | "list-remote" ) nvm_print_versions "`nvm_ls_remote $2`" diff --git "a/test/fast/Running \"nvm ls foo\" should return a nonzero exit code when not found" "b/test/fast/Running \"nvm ls foo\" should return a nonzero exit code when not found" new file mode 100755 index 0000000..b29a947 --- /dev/null +++ "b/test/fast/Running \"nvm ls foo\" should return a nonzero exit code when not found" @@ -0,0 +1,7 @@ + #!/bin/sh + +. ../../nvm.sh + +nvm ls nonexistent_version +[ "$?" = "3" ] +