From 9e17b5059cc81ae2c2eda542c1608f291f01f6db Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 19 Dec 2014 16:12:13 -0800 Subject: [PATCH] Return the proper exit code of `which` directly. --- nvm.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index d5bd9e6..64cdd33 100644 --- a/nvm.sh +++ b/nvm.sh @@ -965,8 +965,14 @@ nvm() { if [ "_$VERSION" = '_system' ]; then if nvm_has_system_node >/dev/null 2>&1; then - echo $(nvm use system > /dev/null 2>&1 && echo $(which node)) - return + local NVM_BIN + NVM_BIN="$(nvm use system >/dev/null 2>&1 && which node)" + if [ -n "$NVM_BIN" ]; then + echo "$NVM_BIN" + return + else + return 1 + fi else echo "System version of node not found." >&2 return 127