Skip to content

Commit 472ba5f

Browse files
committed
Make sure sourcing nvm.sh on shells that don't support source options doesn't exit nonzero.
Fixes #721
1 parent 96c96ec commit 472ba5f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

nvm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,7 @@ nvm_supports_source_options() {
17841784
[ "_$(echo 'echo $1' | . /dev/stdin yes 2> /dev/null)" = "_yes" ]
17851785
}
17861786

1787-
VERSION="$(nvm_alias default 2>/dev/null)"
1787+
VERSION="$(nvm_alias default 2>/dev/null || echo)"
17881788
if nvm_supports_source_options && [ "_$1" = "_--install" ]; then
17891789
if [ -n "$VERSION" ]; then
17901790
nvm install "$VERSION" >/dev/null
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
die () { echo $@ ; exit 1; }
4+
5+
touch ../../alias/default
6+
rm ../../alias/default || die 'removal of default alias failed'
7+
nvm_alias default && die '"nvm_alias default" did not fail'
8+
9+
set -e # necessary to fail internally with a nonzero code
10+
11+
. ../../nvm.sh || die 'sourcing returned nonzero exit code'

0 commit comments

Comments
 (0)