From 88998c35f28161f1ed054efa5b0ff3779a1d7477 Mon Sep 17 00:00:00 2001 From: Xandor Schiefer Date: Tue, 15 Nov 2016 21:47:23 +0200 Subject: [PATCH] Better pre-managed PATH check in nvm_change_path --- nvm.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index 3c4eb69..2dd6bfe 100755 --- a/nvm.sh +++ b/nvm.sh @@ -490,7 +490,8 @@ nvm_change_path() { nvm_echo "${3-}${2-}" # if the initial path doesn’t contain an nvm path, prepend the supplementary # path - elif [ "${1#*$NVM_DIR}" == "$1" ]; then + elif [ `expr "${1-}" : ".*${NVM_DIR}/[^:]*${2-}.*"` = 0 ] || \ + [ `expr "${1-}" : ".*${NVM_DIR}/versions/[^/]*/[^/]*${2-}.*"` = 0 ]; then nvm_echo "${3-}${2-}:${1-}" # use sed to replace the existing nvm path with the supplementary path. This # preserves the order of the path.