From ab7b4daf17153131f051037c1ed7767eb9e3632a Mon Sep 17 00:00:00 2001 From: Charlie Hileman Date: Wed, 8 Jan 2020 12:06:49 -0500 Subject: [PATCH] [Fix] `nvm_tree_contains_path`: handle symbolic links Co-Authored-By: Charlie Hileman Co-Authored-By: Jordan Harband --- nvm.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nvm.sh b/nvm.sh index 83aac75..e671a8a 100644 --- a/nvm.sh +++ b/nvm.sh @@ -311,6 +311,12 @@ nvm_tree_contains_path() { local pathdir pathdir=$(dirname "${node_path}") + + # get real directory in case of symbolic links + if [ -d "${pathdir-}" ]; then + pathdir="$(nvm_cd -P "${pathdir}" && pwd)" + fi + while [ "${pathdir}" != "" ] && [ "${pathdir}" != "." ] && [ "${pathdir}" != "/" ] && [ "${pathdir}" != "${tree}" ]; do pathdir=$(dirname "${pathdir}") done