[Fix] nvm: do not change or export the caller's IFS

`IFS=... nvm "$@"` is a prefix assignment to a function call, which bash's POSIX mode (macOS `/bin/sh`) keeps after the call returns, and exports.
This commit is contained in:
Jordan Harband
2026-09-30 15:50:38 +09:00
parent 3bfc2b4a9a
commit 0add6b8555
2 changed files with 31 additions and 4 deletions
@@ -0,0 +1,19 @@
#!/bin/sh
die () { IFS=' '; echo "$@" ; exit 1; }
: nvm.sh
\. ../../nvm.sh
IFS=':'
nvm --version >/dev/null
[ "${IFS}" = ':' ] || die "nvm changed the caller's IFS; got >${IFS}<"
set -e
nvm --version >/dev/null
set +e
[ "${IFS}" = ':' ] || die "nvm changed the caller's IFS under set -e; got >${IFS}<"
! env | grep -q '^IFS=' || die 'nvm exported IFS'
IFS=' '