nvm/test/fast/Running "nvm unload" should...

31 lines
685 B
Plaintext
Raw Normal View History

2014-03-17 01:16:46 +08:00
#!/bin/sh
set -ex
BEFORE="./before.tmp"
AFTER="./after.tmp"
cleanup () { rm -f "${BEFORE}" "${AFTER}"; }
die () { echo "$@" ; cleanup ; exit 1; }
typeset -f | awk '/ \(\) $/ && !/^main / {print $1}' > "${BEFORE}"
env | grep -v PATH= | grep -v IFS= | grep -v NVM_ | sort >> "${BEFORE}"
2014-03-17 01:16:46 +08:00
set +e # TODO: fix
\. ../../nvm.sh
set -e
2014-03-17 01:16:46 +08:00
type nvm > /dev/null 2>&1 || die "nvm not loaded"
2014-03-17 01:16:46 +08:00
nvm unload
typeset -f | awk '/ \(\) $/ && !/^main / {print $1}' > "${AFTER}"
env | grep -v PATH= | grep -v IFS= | sort >> "${AFTER}"
! type nvm > /dev/null 2>&1 || die "nvm not unloaded"
DIFF="$(diff "${BEFORE}" "${AFTER}" ||:)"
[ -z "${DIFF}" ] || die "function pollution found: ${DIFF}"
cleanup