diff --git a/nvm.sh b/nvm.sh index 1a98f3c..31e0705 100644 --- a/nvm.sh +++ b/nvm.sh @@ -258,10 +258,14 @@ if [ -z "${NVM_DIR-}" ]; then NVM_DIR="$(nvm_cd ${NVM_CD_FLAGS} "$(dirname "${NVM_SCRIPT_SOURCE:-$0}")" > /dev/null && \pwd)" export NVM_DIR else - while echo "${NVM_DIR}" | nvm_grep -q "/$"; do - export NVM_DIR="${NVM_DIR%/}" - done - nvm_err "Warning: \$NVM_DIR should not have trailing slash" + # https://unix.stackexchange.com/a/198289 + case $NVM_DIR in + *[!/]*/) + NVM_DIR="${NVM_DIR%"${NVM_DIR##*[!/]}"}" + export NVM_DIR + nvm_err "Warning: \$NVM_DIR should not have trailing slashes" + ;; + esac fi unset NVM_SCRIPT_SOURCE 2> /dev/null