From 8c9e20ef71e5599b6a8e7aecae21321a77df7092 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 16 Dec 2021 18:53:40 +0100 Subject: [PATCH] modulecmd: normalize paths by replacing multiple slashes with one A trailing slash is also removed. --- Pmodules/modulecmd.bash.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index f998084..8c770e9 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -118,7 +118,8 @@ trap '_exit' EXIT get_overlay_of_moduledir() { local "$1" - local -r moduledir=$2 + local moduledir="${2//+(\/)/\/}" # replace multpile '/' with one + moduledir="${moduledir/%\/}" # remove trailing slash if exist if [[ ! -v Dir2OverlayMap[${moduledir}] ]]; then for overlay in "${OverlayList[@]}" 'other'; do @@ -185,8 +186,10 @@ is_release_stage() { find_overlay () { local "$1" local "$2" - local -r path=$3 - local overlay=${Dir2OverlayMap[${path}]} + local path="${3//+(\/)/\/}" # replace multpile '/' with one + path="${path/%\/}" # remove trailing slash if exist + + local overlay="${Dir2OverlayMap[${path}]}" get_overlay_of_moduledir overlay "${path}" std::upvar $1 "${overlay}"