File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,23 @@ function copy_build_log() {
5353 fi
5454}
5555
56+ function safe_module_use {
57+ # add a given non-empty directory to $MODULEPATH if and only if it is not yet in
58+ directory=${1}
59+
60+ if [[ -z ${directory+x} ]]; then
61+ echo " safe_module_use: given directory unset or empty; not adding it to \$ MODULEPATH (${MODULEPATH} )"
62+ return
63+ fi
64+ if [[ " :${MODULEPATH} :" == * " :${directory} :" * ]]; then
65+ echo " safe_module_use: directory '${directory} ' is already in \$ MODULEPATH (${MODULEPATH} ); not adding it again"
66+ return
67+ else
68+ echo " safe_module_use: directory '${directory} ' is not yet in \$ MODULEPATH (${MODULEPATH} ); adding it"
69+ module use ${directory}
70+ fi
71+ }
72+
5673POSITIONAL_ARGS=()
5774
5875while [[ $# -gt 0 ]]; do
@@ -308,7 +325,8 @@ if [[ "${EESSI_CVMFS_REPO}" == /cvmfs/dev.eessi.io ]]; then
308325fi
309326
310327echo " DEBUG: adding path '$EASYBUILD_INSTALLPATH /modules/all' to MODULEPATH='${MODULEPATH} '"
311- module use $EASYBUILD_INSTALLPATH /modules/all
328+ # module use $EASYBUILD_INSTALLPATH/modules/all
329+ safe_module_use $EASYBUILD_INSTALLPATH /modules/all
312330echo " DEBUG: after adding module path // MODULEPATH='${MODULEPATH} '"
313331
314332if [[ -z ${MODULEPATH} ]]; then
You can’t perform that action at this time.
0 commit comments