mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-10-11 00:00:13 +08:00
[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:
@@ -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=' '
|
||||
Reference in New Issue
Block a user