[Refactor] use a different approach to remove trailing slashes
parent
685312d600
commit
09f7bbb78c
12
nvm.sh
12
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue