modulecmd: fixed in sub-cmd avail

- bugfix in loop collecting per group directories in MODULEPATH
- use UsedGroups to loop over the groups, this defines a clear oder
- in pmodules_init(): prepend groups to UseGroups instead of
  appending. This fixes an issue in the order the groups were listed.
This commit is contained in:
2021-05-06 18:14:07 +02:00
parent a3835d3f0b
commit ab1f6c263d
+10 -11
View File
@@ -1185,27 +1185,26 @@ subcommand_avail() {
IFS=':'
local -a modulepath=(${MODULEPATH})
unset IFS
local overlay=''
local dir
local group=''
local -a groups=()
local overlay=''
for dir in "${modulepath[@]}"; do
group='other'
find_overlay overlay group "${dir}"
if [[ -v modulepath_${group} ]]; then
path+=("${dir}")
else
typeset -a modulepath_${group}="${dir}"
typeset -n path=modulepath_${group}
groups+=("${group}")
if [[ ! -v modulepath_${group} ]]; then
typeset -a modulepath_${group}
fi
typeset -n path=modulepath_${group}
path+=("${dir}")
done
local p
for p in "${pattern[@]}"; do
for group in "${groups[@]}"; do
for group in ${UsedGroups//:/ } other; do
if (( ${#opt_groups[@]} > 0 )) && [[ ! -v opt_groups[${group}] ]]; then
continue
fi
declare -n path=modulepath_${group}
[[ -v modulepath_${group} ]] || continue
typeset -n path=modulepath_${group}
get_available_modules \
mods \
"${p}" \
@@ -1807,7 +1806,7 @@ pmodules_init() {
UsedGroups=''
local group
for group in ${PMODULES_DEFAULT_GROUPS}; do
std::append_path UsedGroups "${group}"
std::prepend_path UsedGroups "${group}"
done
g_env_must_be_saved='yes'
}