mirror of
https://github.com/envmodules/modules.git
synced 2026-06-14 00:42:43 +08:00
118 lines
4.1 KiB
Plaintext
118 lines
4.1 KiB
Plaintext
# disable shell debugging for the run of this init file
|
|
if [ "$MODULES_SILENT_SHELL_DEBUG" = '1' ]; then
|
|
# immediately disable debugging to echo the less number of line possible
|
|
case "$-" in
|
|
*v*x*) set +vx; _mlshdbg='vx' ;;
|
|
*v*) set +v; _mlshdbg='v' ;;
|
|
*x*) set +x; _mlshdbg='x' ;;
|
|
*) _mlshdbg='' ;;
|
|
esac;
|
|
fi;
|
|
|
|
# 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
|
|
_mlre='';
|
|
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}${_mlv}_modquar='`eval 'echo ${'$_mlv'}'`' ";
|
|
fi;
|
|
_mlrv="MODULES_RUNENV_${_mlv}";
|
|
_mlre="${_mlre}${_mlv}='`eval 'echo ${'$_mlrv'}'`' ";
|
|
fi;
|
|
done;
|
|
if [ -n "$_mlre" ]; then
|
|
_mlre="eval ${_mlre}";
|
|
fi;
|
|
|
|
# define module command and surrounding initial environment (default value
|
|
# for MODULESHOME, MODULEPATH, LOADEDMODULES and parse of init/.modulespath)
|
|
eval `${_mlre}@TCLSH@ @libexecdir@/modulecmd.tcl bash autoinit`
|
|
|
|
# clean temp variables used to setup quarantine
|
|
if [ -n "${_mlIFS+x}" ]; then
|
|
IFS=$_mlIFS; unset _mlIFS;
|
|
else
|
|
unset IFS;
|
|
fi;
|
|
unset _mlre _mlv _mlrv
|
|
|
|
@compatversion@# redefine module command if compat version has been activated
|
|
@compatversion@if [ "$MODULES_USE_COMPAT_VERSION" = '1' ]; then
|
|
@compatversion@ MODULES_CMD=@libexecdir@/modulecmd-compat; export MODULES_CMD
|
|
@compatversion@ if [ -t 1 ]; then
|
|
@compatversion@ _moduleraw() { eval `@libexecdir@/modulecmd-compat bash $*`; }
|
|
@compatversion@ else
|
|
@compatversion@ module() { eval `@libexecdir@/modulecmd-compat bash $*`; }
|
|
@compatversion@ fi
|
|
@compatversion@fi
|
|
@compatversion@
|
|
# export functions to get them defined in sub-shells
|
|
if [ -t 1 ]; then
|
|
export -f _moduleraw
|
|
fi
|
|
export -f module
|
|
|
|
@compatversion@# define function to switch between C and Tcl versions of Modules
|
|
@compatversion@switchml() {
|
|
@compatversion@ typeset swfound=1
|
|
@compatversion@ if [ "$MODULES_USE_COMPAT_VERSION" = '1' ]; then
|
|
@compatversion@ typeset swname='main'
|
|
@compatversion@ if [ -e @libexecdir@/modulecmd.tcl ]; then
|
|
@compatversion@ typeset swfound=0
|
|
@compatversion@ unset MODULES_USE_COMPAT_VERSION
|
|
@compatversion@ fi
|
|
@compatversion@ else
|
|
@compatversion@ typeset swname='compatibility'
|
|
@compatversion@ if [ -e @libexecdir@/modulecmd-compat ]; then
|
|
@compatversion@ typeset swfound=0
|
|
@compatversion@ MODULES_USE_COMPAT_VERSION=1; export MODULES_USE_COMPAT_VERSION
|
|
@compatversion@ fi
|
|
@compatversion@ fi
|
|
@compatversion@
|
|
@compatversion@ # switch version only if command found
|
|
@compatversion@ if [ $swfound -eq 0 ]; then
|
|
@compatversion@ echo "Switching to Modules $swname version"
|
|
@compatversion@ source @initdir@/bash
|
|
@compatversion@ else
|
|
@compatversion@ echo "Cannot switch to Modules $swname version, command not found"
|
|
@compatversion@ return 1
|
|
@compatversion@ fi
|
|
@compatversion@}
|
|
@compatversion@export -f switchml
|
|
@compatversion@
|
|
# setup ENV variables to get module defined in sub-shells (works for 'sh'
|
|
# and 'ksh' in interactive mode and 'sh' (zsh-compat), 'bash' and 'ksh'
|
|
# (zsh-compat) in non-interactive mode.
|
|
ENV=@initdir@/profile.sh; export ENV
|
|
BASH_ENV=@initdir@/bash; export BASH_ENV
|
|
|
|
# enable completion only in interactive mode
|
|
if [ ${BASH_VERSINFO:-0} -ge 3 ] && [[ $- =~ i ]] &&
|
|
[ -r @initdir@/bash_completion ]; then
|
|
source @initdir@/bash_completion
|
|
fi
|
|
|
|
@setbinpath@if [[ ! ":$PATH:" =~ ':@bindir@:' ]]; then
|
|
@setbinpath@ PATH=@bindir@${PATH:+:}$PATH; export PATH
|
|
@setbinpath@fi
|
|
@setbinpath@
|
|
@setmanpath@manpath=`manpath 2>/dev/null`
|
|
@setmanpath@if [[ ! ":$manpath:" =~ ':@mandir@:' ]]; then
|
|
@setmanpath@ MANPATH=@mandir@${manpath:+:}$manpath; export MANPATH
|
|
@setmanpath@fi
|
|
@setmanpath@
|
|
# restore shell debugging options if disabled
|
|
if [ -n "$_mlshdbg" ]; then
|
|
set -$_mlshdbg;
|
|
unset _mlshdbg;
|
|
fi;
|