diff --git a/nvs b/nvs index e2d2f31a..4f77da1f 100755 --- a/nvs +++ b/nvs @@ -8,7 +8,9 @@ # Enable the nvsudo() shell function to modify the PATH of the sudo environment. if [ -n "${NVS_CURRENT}" ]; then - export PATH="${NVS_CURRENT}:$PATH" + if [[ ! "$PATH" == *"${NVS_CURRENT}:"* ]]; then + export PATH="${NVS_CURRENT}:$PATH" + fi fi export NVS_EXECUTE=1 diff --git a/nvs.sh b/nvs.sh index b24763a1..45cef3be 100644 --- a/nvs.sh +++ b/nvs.sh @@ -226,10 +226,14 @@ fi # If some version is linked as the default, begin by using that version. if [ -d "${NVS_HOME}/default" ]; then if [ -f "${NVS_HOME}/default/bin/node" ]; then - export PATH="${NVS_HOME}/default/bin:${PATH}" + if [[ ! "$PATH" == *"${NVS_HOME}/default/bin"* ]]; then + export PATH="${NVS_HOME}/default/bin:${PATH}" + fi unset NPM_CONFIG_PREFIX elif [ -f "${NVS_HOME}/default/node" ]; then - export PATH="${NVS_HOME}/default:${PATH}" + if [[ ! "$PATH" == *"${NVS_HOME}/default/bin"* ]]; then + export PATH="${NVS_HOME}/default:${PATH}" + fi unset NPM_CONFIG_PREFIX fi fi