From 08805399729e3e17a96c4ff1ae53c243d81272c5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 8 May 2016 20:05:59 -0700 Subject: [PATCH] `nvm_strip_path`: Error out when `$NVM_DIR` is not set. Per https://github.com/creationix/nvm/issues/1083#issuecomment-217752185 --- nvm.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nvm.sh b/nvm.sh index 075f884..010801e 100644 --- a/nvm.sh +++ b/nvm.sh @@ -403,6 +403,10 @@ nvm_num_version_groups() { } nvm_strip_path() { + if [ -z "${NVM_DIR-}" ]; then + nvm_err '$NVM_DIR not set!' + return 1 + fi nvm_echo "$1" | command sed \ -e "s#$NVM_DIR/[^/]*$2[^:]*:##g" \ -e "s#:$NVM_DIR/[^/]*$2[^:]*##g" \