Files
modules/init/bash.in
Xavier Delaruelle 956b377873 Restore quarantine if __MODULES_QUARANTINE_SET defined
Introduce the __MODULES_QUARANTINE_SET environment variable to put back
when starting modulecmd.tcl run the environment set on hold by
initialization script (for autoinit calls) or by module shell function
(for regular calls).

This new environment variable is tested to apply quarantine unhold
mechanism instead of checking if the run_quarantine configuration option
is set and shell accurately supports the mecanishm. With this change it
is possible to enable or disable the quarantine support at module
initialization time (through initrc configuration file) instead of
freezing this configuration when building the modulecmd.tcl script.
2021-08-25 07:29:16 +02:00

103 lines
3.6 KiB
Plaintext

@silentshdbgsupport@unset _mlshdbg;
@silentshdbgsupport@# disable shell debugging for the run of this init file
@silentshdbgsupport@if [ "${MODULES_SILENT_SHELL_DEBUG:-0}" = '1' ]; then
@silentshdbgsupport@ # immediately disable debugging to echo the less number of line possible
@silentshdbgsupport@ case "$-" in
@silentshdbgsupport@ *v*x*) set +vx; _mlshdbg='vx' ;;
@silentshdbgsupport@ *v*) set +v; _mlshdbg='v' ;;
@silentshdbgsupport@ *x*) set +x; _mlshdbg='x' ;;
@silentshdbgsupport@ *) _mlshdbg='' ;;
@silentshdbgsupport@ esac;
@silentshdbgsupport@fi;
@silentshdbgsupport@
# define modules runtine quarantine configuration
@setquarvars@export MODULES_RUN_QUARANTINE='@RUN_QUARANTINE@'
@setquarvars@@export RUNENV_VAR='RUNENV_VAL'@
@notsetquarvars@#export MODULES_RUN_QUARANTINE='ENVVARNAME'
@notsetquarvars@
# setup quarantine if defined
unset _mlre _mlIFS;
if [ -n "${IFS+x}" ]; then
_mlIFS=$IFS;
fi;
IFS=' ';
for _mlv in ${MODULES_RUN_QUARANTINE:-}; do
if [ "${_mlv}" = "${_mlv##*[!A-Za-z0-9_]}" -a "${_mlv}" = "${_mlv#[0-9]}" ]; then
if [ -n "`eval 'echo ${'$_mlv'+x}'`" ]; then
_mlre="${_mlre:-}__MODULES_QUAR_${_mlv}='`eval 'echo ${'$_mlv'}'`' ";
fi;
_mlrv="MODULES_RUNENV_${_mlv}";
_mlre="${_mlre:-}${_mlv}='`eval 'echo ${'$_mlrv':-}'`' ";
fi;
done;
if [ -n "${_mlre:-}" ]; then
_mlre="eval ${_mlre}__MODULES_QUARANTINE_SET=1 ";
fi;
# define module command and surrounding initial environment (default value
# for MODULESHOME, MODULEPATH, LOADEDMODULES and parse of init config files)
_mlcode=`${_mlre:-}@TCLSH@ @libexecdir@/modulecmd.tcl bash autoinit`
_mlret=$?
# clean temp variables used to setup quarantine
if [ -n "${_mlIFS+x}" ]; then
IFS=$_mlIFS;
unset _mlIFS;
else
unset IFS;
fi;
unset _mlre _mlv _mlrv
# no environment alteration if the above autoinit command failed
if [ $_mlret -eq 0 ]; then
eval "$_mlcode"
# export functions to get them defined in sub-shells
if [ -t 2 ]; then
export -f _module_raw
fi
export -f module
if [ "$(type -t ml)" = 'function' ]; then
export -f ml
fi
# enable completion only in interactive mode
if [ ${BASH_VERSINFO:-0} -ge 3 ] && [[ $- =~ i ]] &&
[ -r @initdir@/bash_completion ]; then
source @initdir@/bash_completion
fi
@setbinpath@
@setbinpath@ if [[ ! ":$PATH:" =~ ':@bindir@:' ]]; then
@setbinpath@@prependbinpath@ PATH=@bindir@${PATH:+:}$PATH
@setbinpath@@appendbinpath@ PATH=$PATH${PATH:+:}@bindir@
@setbinpath@ export PATH
@setbinpath@ fi
@setmanpath@
@setmanpath@ # initialize MANPATH if not set with a value that preserves manpath system
@setmanpath@ # configuration even after addition of paths to this variable by modulefiles
@setmanpath@ if [ ! -n "${MANPATH+x}" ]; then
@setmanpath@ MANPATH=:
@setmanpath@ export MANPATH
@setmanpath@ fi
@setmanpath@@usemanpath@ if [[ ! ":`manpath 2>/dev/null`:" =~ ':@mandir@:' ]]; then
@setmanpath@@notusemanpath@ if [[ ! ":$MANPATH:" =~ ':@mandir@:' ]]; then
@setmanpath@ if [ "$MANPATH" = ':' ] || [ "$MANPATH" = '' ]; then
@setmanpath@ _mlpathsep=''
@setmanpath@ else
@setmanpath@ _mlpathsep=:
@setmanpath@ fi
@setmanpath@@prependmanpath@ MANPATH=@mandir@$_mlpathsep$MANPATH
@setmanpath@@appendmanpath@ MANPATH=$MANPATH$_mlpathsep@mandir@
@setmanpath@ export MANPATH
@setmanpath@ unset _mlpathsep
@setmanpath@ fi
fi
unset _mlcode _mlret
@silentshdbgsupport@
@silentshdbgsupport@# restore shell debugging options if disabled
@silentshdbgsupport@if [ -n "${_mlshdbg:-}" ]; then
@silentshdbgsupport@ set -$_mlshdbg;
@silentshdbgsupport@ unset _mlshdbg;
@silentshdbgsupport@fi;