From 6375e4ed79dc584a8174e5816d68a1c31b6d9b27 Mon Sep 17 00:00:00 2001 From: Jahir Raihan Joy Date: Thu, 9 May 2024 16:24:33 +0600 Subject: [PATCH] converted tree path to canonical form for case-insensitive comp --- nvm.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index 2e4378f2d2..0d1ee7f349 100644 --- a/nvm.sh +++ b/nvm.sh @@ -417,6 +417,7 @@ else fi unset NVM_SCRIPT_SOURCE 2>/dev/null + nvm_tree_contains_path() { local tree tree="${1-}" @@ -432,14 +433,21 @@ nvm_tree_contains_path() { previous_pathdir="${node_path}" local pathdir pathdir=$(dirname "${previous_pathdir}") + + # Convert tree path to canonical form for case-insensitive comparison + local tree_canonical + tree_canonical=$(cd "${tree}" && pwd -P) + while [ "${pathdir}" != '' ] && [ "${pathdir}" != '.' ] && [ "${pathdir}" != '/' ] && - [ "${pathdir}" != "${tree}" ] && [ "${pathdir}" != "${previous_pathdir}" ]; do + [ "${pathdir}" != "${tree_canonical}" ] && [ "${pathdir}" != "${previous_pathdir}" ]; do previous_pathdir="${pathdir}" pathdir=$(dirname "${previous_pathdir}") done - [ "${pathdir}" = "${tree}" ] + + [ "${pathdir}" = "${tree_canonical}" ] } + nvm_find_project_dir() { local path_ path_="${PWD}"