modulecmd: additional directories in overlays

This commit is contained in:
2024-08-14 14:28:11 +02:00
parent 8e40fb118b
commit 2653bb86b3
2 changed files with 31 additions and 2 deletions
+8
View File
@@ -79,6 +79,7 @@ declare -A OverlayConfigKeys=(
['modulefiles_root']=''
['excludes']=''
['type']='n'
['modulepath']=''
)
pm::get_value(){
@@ -186,6 +187,13 @@ pm::read_config(){
printf -v excludes "%s:" "${tmp_array[@]}"
OverlayInfo[${ol_name}:excludes]=$(${envsubst} <<<"${excludes%:}" )
;;
modulepath )
pm::get_seq "${yaml_input}" value "${key}" '!!seq'
local -a tmp_array=()
readarray -t tmp_array <<<${value}
local modulepath=''
printf -v modulepath "%s:" "${tmp_array[@]}"
OverlayInfo[${ol_name}:modulepath]=$(${envsubst} <<< "${modulepath%:}")
;;
esac
done
+23 -2
View File
@@ -1685,6 +1685,15 @@ subcommand_use() {
fi
done
if [[ -v OverlayInfo[${ol_name}:modulepath] && \
-n "${OverlayInfo[${ol_name}:modulepath]}" ]]; then
local -a modulepath=()
IFS=':' read -r -a modulepath <<<"${OverlayInfo[${ol_name}:modulepath]}"
local -- dir=''
for dir in "${modulepath[@]}"; do
std::prepend_path MODULEPATH "${dir}"
done
fi
UsedOverlays=( "${ol_name}" "${UsedOverlays[@]}" )
OverlayInfo[${ol_name}:used]='yes'
@@ -1866,13 +1875,25 @@ subcommand_unuse() {
done
done
EnvMustBeSaved='yes'
export_env UsedOverlays
# remove additional directories added overlay
if [[ -v OverlayInfo[${ol_name}:modulepath] && \
-n "${OverlayInfo[${ol_name}:modulepath]}" ]]; then
local -a modulepath=()
IFS=':' read -r -a modulepath <<<"${OverlayInfo[${ol_name}:modulepath]}"
local -- dir=''
for dir in "${modulepath[@]}"; do
std::remove_path MODULEPATH "${dir}"
done
fi
# remove root of overlay
local dir
for dir in "${modulepath[@]}"; do
[[ "${dir}" == "${OverlayInfo[${ol_name}:modulefiles_root]}" ]] && \
std::remove_path MODULEPATH "${dir}"
done
export_env UsedOverlays
EnvMustBeSaved='yes'
}
#..............................................................