From da3d5ecd98a5c5a996ac40822207edd2ed844848 Mon Sep 17 00:00:00 2001 From: gsell Date: Fri, 23 Aug 2024 13:32:14 +0200 Subject: [PATCH] Merge branch '333-modulecmd-module-use-group-adds-directories-of-overlays-in-wrong-order' into 'master' Resolve "modulecmd: 'module use GROUP' adds directories of overlays in wrong order" Closes #333 See merge request Pmodules/src!312 (cherry picked from commit ea28d5c0fd9288e861e34263919959b79cd88372) 84f3ab67 modulecmd: fix order of dirs in MODULEPATH Co-authored-by: gsell --- Pmodules/modulecmd.bash.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 47419b7..9edf731 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -1795,11 +1795,13 @@ subcommand_use() { die_illegal_group "${arg}" std::append_path UsedGroups "$1" - local ol_name - for ol_name in "${UsedOverlays[@]}"; do + local -- ol_name + local -i i=0 + local -i n="${#UsedOverlays[@]}" + for ((i=n-1; i>=0; i--)); do + ol_name="${UsedOverlays[i]}" local dir="${OverlayInfo[${ol_name}:modulefiles_root]}/$1/${PMODULES_MODULEFILES_DIR}" [[ -d "${dir}" ]] || continue - std::prepend_path MODULEPATH "${dir}" [[ "${OverlayInfo[${ol_name}:type]}" == "${ol_replacing}" ]] && break done