From 58d0933f72c3b819d8180e3fe68b66201a87c0a4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 23 Feb 2019 22:21:46 -0800 Subject: [PATCH] [Fix] attempt to fix a bug in bash 3.2, fixed in 4.4, that improperly exits on `-e` in a test. See https://gist.github.com/ljharb/6e70a79ac5fcf11a8b9de654a88642aa for details. --- nvm.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index 4906a92..0dcd274 100644 --- a/nvm.sh +++ b/nvm.sh @@ -2300,7 +2300,14 @@ nvm() { local DEFAULT_IFS DEFAULT_IFS=" $(nvm_echo t | command tr t \\t) " - if [ "${IFS}" != "${DEFAULT_IFS}" ]; then + if [ "${-#*e}" != "$-" ]; then + set +e + local EXIT_CODE + IFS="${DEFAULT_IFS}" nvm "$@" + EXIT_CODE=$? + set -e + return $EXIT_CODE + elif [ "${IFS}" != "${DEFAULT_IFS}" ]; then IFS="${DEFAULT_IFS}" nvm "$@" return $? fi