mirror of
https://github.com/Pmodules/Pmodules.git
synced 2026-06-28 10:29:37 +02:00
modulecmd/libpmodules.bash: interface of compute_group_depth() changed
retrun result in a reference variable
This commit is contained in:
@@ -38,18 +38,17 @@ print_help() {
|
||||
# $1: absolute path of a modulefile directory
|
||||
#
|
||||
compute_group_depth () {
|
||||
local -r dir=$1
|
||||
local -n result="$1"
|
||||
local -r dir="$2"
|
||||
test -d "${dir}" || return 1
|
||||
local group=${dir%/*}
|
||||
local group=${group##*/}
|
||||
[[ -n "${GroupDepths[${group}]}" ]] && return 0
|
||||
local -i depth=$(${find} "${dir}" -depth \( -type f -o -type l \) \
|
||||
local -i result=$(${find} "${dir}" -depth \( -type f -o -type l \) \
|
||||
-printf "%d" -quit 2>/dev/null)
|
||||
(( depth-=2 ))
|
||||
(( result-=2 ))
|
||||
# if a group doesn't contain a modulefile, depth is negativ
|
||||
# :FIXME: better solution?
|
||||
(( depth < 0 )) && (( depth = 0 ))
|
||||
GroupDepths[$group]=${depth}
|
||||
(( result < 0 )) && (( result = 0 ))
|
||||
}
|
||||
|
||||
#
|
||||
@@ -62,9 +61,13 @@ scan_groups () {
|
||||
local ol
|
||||
for ol in "$@"; do
|
||||
local mod_root="${OverlayInfo[${ol}:mod_root]}"
|
||||
local -i depth
|
||||
local dir
|
||||
for dir in ${mod_root}/*/${PMODULES_MODULEFILES_DIR}; do
|
||||
compute_group_depth "${dir}"
|
||||
if [[ -n "${GroupDepths[${group}]}" ]]; then
|
||||
compute_group_depth depth "${dir}"
|
||||
GroupDepths[$group]=${depth}
|
||||
fi
|
||||
Dir2OverlayMap[${dir%/${PMODULES_MODULEFILES_DIR}*}]="${ol}"
|
||||
done
|
||||
done
|
||||
|
||||
@@ -484,7 +484,9 @@ subcommand_load() {
|
||||
local ol=''
|
||||
find_overlay_with_group ol "${group}" || return 1
|
||||
local moduledir="${OverlayInfo[${ol}:mod_root]}/${group}/${PMODULES_MODULEFILES_DIR}"
|
||||
compute_group_depth "${moduledir}" || return 1
|
||||
local -i depth
|
||||
compute_group_depth depth "${moduledir}" || return 1
|
||||
GroupDepths[${group}]=${depth}
|
||||
g_env_must_be_saved='yes'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user