[Fix] nvm_tree_contains_path: handle symbolic links

Co-Authored-By: Charlie Hileman <aiquicorp@gmail.com>
Co-Authored-By: Jordan Harband <ljharb@gmail.com>
This commit is contained in:
Charlie Hileman 2020-01-08 12:06:49 -05:00 committed by Jordan Harband
parent ea3b65f02e
commit 9222739d18
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56

6
nvm.sh
View File

@ -407,6 +407,12 @@ nvm_tree_contains_path() {
previous_pathdir="${node_path}"
local pathdir
pathdir=$(dirname "${previous_pathdir}")
# 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}" ] && [ "${pathdir}" != "${previous_pathdir}" ]; do
previous_pathdir="${pathdir}"