Files
modules/init/bash.in
Xavier Delaruelle 519d08e98d init: shell scripts now rely on autoinit command
Make use of autoinit module command to initialize module command and its
initial surrounding environment (default value for MODULESHOME,
MODULEPATH, LOADEDMODULES and parse of init/.modulespath).

Then if compatibility version is currently activated redefined the
module command to point to the compat binary. But the compat version
will benefit from the surrounding environment initialization made by
autoinit.

With this change, activated compatibility version will also get its
environment initialized by the init/modulerc file whereas before this
change only the main version was affected by this setup file.
2017-10-23 22:35:27 +02:00

68 lines
2.7 KiB
Plaintext

# define module command and surrounding initial environment (default value
# for MODULESHOME, MODULEPATH, LOADEDMODULES and parse of init/.modulespath)
eval `@TCLSH@ @libexecdir@/modulecmd.tcl bash autoinit`
@compatversion@# redefine module command if compat version has been activated
@compatversion@if [ "$MODULES_USE_COMPAT_VERSION" = '1' ]; then
@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