[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)"
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