Add error checking to nvm_tree_contains_path

This commit is contained in:
Jordan Harband
2014-08-21 17:15:53 -07:00
parent 6e6c5c4e2a
commit 5c7f08843d
2 changed files with 11 additions and 0 deletions

6
nvm.sh
View File

@@ -58,6 +58,12 @@ nvm_tree_contains_path() {
tree="$1"
local node_path
node_path="$2"
if [ "@$tree@" = "@@" ] || [ "@$node_path@" = "@@" ]; then
>&2 echo "both the tree and the node path are required"
return 2
fi
local pathdir
pathdir=$(dirname "$node_path")
while [ "$pathdir" != "" ] && [ "$pathdir" != "." ] && [ "$pathdir" != "/" ] && [ "$pathdir" != "$tree" ]; do