From 5661f69169b24768dae9968eac2ac58b12df9789 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 22 Apr 2021 09:45:39 +0200 Subject: [PATCH] modulecmd: get_available_modules(): bugfix - it was expected that all modules are in an overlay. This is wrong. a user may add a modulefile directory with module use DIR. --- Pmodules/modulecmd.bash.in | 40 ++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index bc25b65..70b2079 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -846,26 +846,32 @@ get_available_modules() { "${dir}" \ "${mod}" [[ :${releases}: =~ ${release} ]] || continue - # - # add to list of available modules, if - # - first time found by name only - # - in same overlay as first found - # - new version and not hidden by overlay - local name="${mod%/*}" local add='no' - if [[ -z "${modulenames[${name}]}" ]]; then - if [[ "${Overlays[$overlay]}" == 'h' ]]; then - modulenames[${name}]="${overlay}" - else - modulenames[${name}]='0' + if [[ -n "${overlay}" ]]; then + # module is in an overlay + # + # add to list of available modules, if + # - first time found by name only + # - in same overlay as first found + # - new version and not hidden by overlay + local name="${mod%/*}" + if [[ -z "${modulenames[${name}]}" ]]; then + if [[ "${Overlays[$overlay]}" == 'h' ]]; then + modulenames[${name}]="${overlay}" + else + modulenames[${name}]='0' + fi + add='yes' + elif [[ "${modulenames[${name}]}" == "${overlay}" ]]; then + add='yes' + elif [[ "${modulenames[${name}]}" == '0' ]] \ + && [[ -z ${dict[${mod}]} ]]; then + add='yes' fi + else + # module is NOT in an overlay add='yes' - elif [[ "${modulenames[${name}]}" == "${overlay}" ]]; then - add='yes' - elif [[ "${modulenames[${name}]}" == '0' ]] \ - && [[ -z ${dict[${mod}]} ]]; then - add='yes' - fi + fi if [[ "${add}" == 'yes' ]]; then mods+=( "${mod}" ${release} "${dir}/${mod}" ) dict[${mod}]=1