Commit 9ad827b3 authored by gsell's avatar gsell

scripts/Bootstrap/Pmodules/modulecmd.bash.in:

- support for release in extendet module name added
parent 8170da8d
......@@ -447,6 +447,10 @@ is_used_release() {
declare used_groups=":${PMODULES_USED_GROUPS}:"
is_group () {
[[ -n ${group} ]] && [[ -n ${HierarchyDepths[${group}]} ]]
}
is_used_group() {
[[ ${used_groups} =~ :$1: ]]
}
......@@ -577,6 +581,7 @@ subcommand_load() {
IFS=${saved_IFS}
local -r saved_MODULEPATH=${MODULEPATH}
local -a saved_modulepath=${modulepath}
local -r saved_UsedReleases=${UsedReleases}
#
# Test whether a given module can be loaded according to the
......@@ -748,21 +753,55 @@ subcommand_load() {
# restore original MODULEPATH; it might have been overwritten
MODULEPATH=${saved_MODULEPATH}
modulepath=${saved_modulepath}
UsedReleases=${saved_UsedReleases}
if [[ "$m" =~ ":" ]]; then
# extendet module name is either
# - group:name or
# - group:name:release or
# - release:name or
# - release:group:name or
# - name:release
local save_ifs=${IFS}
IFS=':'
local -a toks=($m)
IFS=${save_ifs}
[[ ${#toks[@]} > 2 ]] && die 3 "${CMD} load: illegal module name."
local group=${toks[0]}
m=${toks[1]}
[[ -z ${HierarchyDepths[${group}]} ]] && die 3 "${CMD} load: illegal group name."
local -i depth=${HierarchyDepths[${group}]}
if (( depth == 0 )); then
local group=''
local release=''
if is_group "${toks[0]}"; then
group=${toks[0]}
m=${toks[1]}
release=${toks[2]}
elif is_release "${toks[0]}"; then
release=${toks[0]}
if is_group "${toks[1]}"; then
group=${toks[1]}
m=${toks[2]}
else
m=${toks[1]}
group=${toks[2]}
fi
else
m=${toks[0]}
if is_group "${toks[1]}"; then
group=${toks[1]}
release=${toks[2]}
else
release=${toks[1]}
group=${toks[2]}
fi
fi
if [[ -n ${group} ]]; then
is_group "${group}" || die 3 "${CMD} load: illegal group name."
local -i depth=${HierarchyDepths[${group}]}
(( depth != 0 )) && die 3 "${CMD} load: illegal group name."
MODULEPATH="${PMODULES_ROOT}/${group}/${PMODULES_MODULEFILES_DIR}"
modulepath=( ${MODULEPATH} )
else
:
fi
if [[ -n ${release} ]]; then
is_release "${release}" || die 3 "${CMD} load: illegal release name."
append_path UsedReleases "${release}"
fi
fi
if is_available "${m}"; then
......@@ -778,6 +817,9 @@ subcommand_load() {
fi
fi
done
# restore original MODULEPATH; it might have been overwritten
MODULEPATH=${saved_MODULEPATH}
UsedReleases=${saved_UsedReleases}
}
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment