[Fix] set -E: Add test for node install on Bash with an ERR trap and set -E

This commit is contained in:
Luke Arms
2021-12-27 16:02:25 +11:00
committed by Jordan Harband
parent fb4538b360
commit 81f0f3ec19
2 changed files with 59 additions and 0 deletions

9
nvm.sh
View File

@@ -2742,6 +2742,15 @@ nvm() {
EXIT_CODE="$?"
set -a
return "$EXIT_CODE"
elif [ -n "${BASH-}" ] && [ "${-#*E}" != "$-" ]; then
# shellcheck disable=SC3041
set +E
local EXIT_CODE
IFS="${DEFAULT_IFS}" nvm "$@"
EXIT_CODE="$?"
# shellcheck disable=SC3041
set -E
return "$EXIT_CODE"
elif [ "${IFS}" != "${DEFAULT_IFS}" ]; then
IFS="${DEFAULT_IFS}" nvm "$@"
return "$?"