match against whole PATH segments

string replacement still doesn't match against asdf segments when last in PATH
This commit is contained in:
James Hegedus 2018-03-09 01:01:09 +11:00
parent f8c9e97900
commit d3895f593c

View File

@ -13,10 +13,10 @@ ASDF_DIR="$(cd "$(dirname "$current_script_path")" &> /dev/null || exit 1; pwd)"
# #
# if in $PATH, remove, regardless of if it is in the right place (at the front) or not. # if in $PATH, remove, regardless of if it is in the right place (at the front) or not.
# replace all occurrences - ${parameter//pattern/string} # replace all occurrences - ${parameter//pattern/string}
ASDF_BIN="${ASDF_DIR}/bin:" ASDF_BIN="${ASDF_DIR}/bin"
ASDF_SHIMS="${ASDF_DIR}/shims:" ASDF_SHIMS="${ASDF_DIR}/shims"
[[ ":$PATH:" == *"${ASDF_BIN}"* ]] && PATH="${PATH//$ASDF_BIN/}" [[ ":$PATH:" == *":${ASDF_BIN}:"* ]] && PATH="${PATH//$ASDF_BIN:/}"
[[ ":$PATH:" == *"${ASDF_SHIMS}"* ]] && PATH="${PATH//$ASDF_SHIMS/}" [[ ":$PATH:" == *":${ASDF_SHIMS}:"* ]] && PATH="${PATH//$ASDF_SHIMS:/}"
# add to front of $PATH # add to front of $PATH
PATH="${ASDF_BIN}$PATH" PATH="${ASDF_BIN}$PATH"
PATH="${ASDF_SHIMS}$PATH" PATH="${ASDF_SHIMS}$PATH"