modulecmd/libpmodules: bugfixes in scaning group depths

This commit is contained in:
2022-06-30 18:23:20 +02:00
parent 81a10f5b55
commit d9a1771838
+5 -3
View File
@@ -43,7 +43,7 @@ compute_group_depth () {
test -d "${dir}" || return 1
local group=${dir%/*}
local group=${group##*/}
local -i result=$(${find} "${dir}" -depth \( -type f -o -type l \) \
result=$(${find} "${dir}" -depth \( -type f -o -type l \) \
-printf "%d" -quit 2>/dev/null)
(( result-=2 ))
# if a group doesn't contain a modulefile, depth is negativ
@@ -59,12 +59,14 @@ compute_group_depth () {
#
scan_groups () {
local ol
local depth
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
if [[ -n "${GroupDepths[${group}]}" ]]; then
local group="${dir%/*}"
group="${group##*/}"
if [[ ! -v GroupDepths[${group}] ]]; then
compute_group_depth depth "${dir}"
GroupDepths[$group]=${depth}
fi