From 1932db23d0c1e526b7cdb38577d034fd1eff6c29 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 28 Apr 2021 00:54:29 +0200 Subject: [PATCH] modulecmd.bash.in: sub.._avail(): use variable reference not dict using a variable reference makes it possible to pass an array to get_available_modules() insteas a colon separated string --- Pmodules/modulecmd.bash.in | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 3e5fdd4..0443ed7 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -1170,26 +1170,27 @@ subcommand_avail() { unset IFS local overlay='' local group='' - local -A modulepath_of_group local -a groups=() for dir in "${modulepath[@]}"; do group='other' find_overlay overlay group "${dir}" - if [[ ${modulepath_of_group[${group}]} ]]; then - modulepath_of_group[${group}]+=:${dir} - else - modulepath_of_group[${group}]=${dir} - groups+=( "${group}" ) - fi + if [[ -v modulepath_${group} ]]; then + path+=("${dir}") + else + typeset -a modulepath_${group}="${dir}" + typeset -n path=modulepath_${group} + groups+=("${group}") + fi done - local string - for string in "${pattern[@]}"; do + local p + for p in "${pattern[@]}"; do for group in "${groups[@]}"; do + declare -n path=modulepath_${group} get_available_modules \ mods \ - "${string}" \ + "${p}" \ "${opt_use_releases}" \ - "${modulepath_of_group[${group}]}" + "${path[@]}" [[ ${#mods[@]} == 0 ]] && continue