[Refactor] use a different approach to remove trailing slashes

Jordan Harband 2018-04-24 13:24:08 -07:00
parent 685312d600
commit 09f7bbb78c
No known key found for this signature in database
GPG Key ID: 64A196AEE0916D55
1 changed files with 8 additions and 4 deletions

12
nvm.sh
View File

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