[Fix] nvm install: fix nvm err typo to nvm_err for -s/-b conflict

The error message for using `-s` and `-b` together was calling
`nvm err` (invoking nvm with subcommand "err") instead of the
`nvm_err` helper function, causing the error message to never be displayed and instead showing the help text with exit code 127.

Bug introduced in 4fdef427e4 / #2439
This commit is contained in:
Jordan Harband
2026-03-14 09:38:04 -07:00
parent ef1620361a
commit 6f428a10bb
2 changed files with 20 additions and 2 deletions

4
nvm.sh
View File

@@ -3439,7 +3439,7 @@ nvm() {
shift # consume "-s"
nobinary=1
if [ $nosource -eq 1 ]; then
nvm err '-s and -b cannot be set together since they would skip install from both binary and source'
nvm_err '-s and -b cannot be set together since they would skip install from both binary and source'
return 6
fi
;;
@@ -3447,7 +3447,7 @@ nvm() {
shift # consume "-b"
nosource=1
if [ $nobinary -eq 1 ]; then
nvm err '-s and -b cannot be set together since they would skip install from both binary and source'
nvm_err '-s and -b cannot be set together since they would skip install from both binary and source'
return 6
fi
;;

View File

@@ -0,0 +1,18 @@
#!/bin/sh
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh
EXPECTED_ERR='-s and -b cannot be set together since they would skip install from both binary and source'
try_err nvm install -s -b 0.10.0
[ "${CAPTURED_EXIT_CODE}" = "6" ] || die "Expected exit code 6 for -s -b, got ${CAPTURED_EXIT_CODE}"
[ "${CAPTURED_STDERR}" = "${EXPECTED_ERR}" ] || die "Expected >${EXPECTED_ERR}<, got >${CAPTURED_STDERR}<"
try_err nvm install -b -s 0.10.0
[ "${CAPTURED_EXIT_CODE}" = "6" ] || die "Expected exit code 6 for -b -s, got ${CAPTURED_EXIT_CODE}"
[ "${CAPTURED_STDERR}" = "${EXPECTED_ERR}" ] || die "Expected >${EXPECTED_ERR}<, got >${CAPTURED_STDERR}<"