Files
Pmodules/Pmodules/bash
T
gsell 85c89df9f5 initialization of Pmodules environment reviewed
- introduce new configuration file ${PMODULES_ROOT}/config/Pmodules.conf
- move as much as possible from profile.bash and init/bash to
  modulecmd
- expose less environment variables to the user
2021-05-26 16:43:38 +02:00

57 lines
1.5 KiB
Bash

#!/bin/bash
#############################################################################
# bash 3 or newer ...
#
if [ ${BASH_VERSINFO:-0} -lt 3 ]; then
echo "BASH version ${BASH_VERSION} ist not supported! You need at least version 3..."
return 1
fi
############################################################################
# some sanity checks
#
if [[ ! -d ${PMODULES_ROOT} ]]; then
echo "Oops: ${PMODULES_ROOT}: Set as Pmodules root, but this is not a directory." 1>&2
return 1
fi
if [[ ! -d ${PMODULES_HOME} ]]; then
echo "Oops: ${PMODULES_HOME}: Set as Pmodules home, but this is not a directory." 1>&2
return 1
fi
#############################################################################
# initialize bash completion
#
if [[ -r "${PMODULES_HOME}/init/bash_completion" ]]; then
source "${PMODULES_HOME}/init/bash_completion"
fi
#############################################################################
# legacy...
#
unset MODULE_VERSION
unset MODULE_VERSION_STACK
unset MODULESHOME
unset PMODULES_ENV
declare -x PMODULES_MODULEFILES_DIR='modulefiles'
declare -x PMODULES_CONFIG_DIR='config'
declare -x PMODULES_DIR="${PMODULES_HOME}"
#############################################################################
# implement module comand as shell function
#
module() {
unset BASH_ENV
eval $("${PMODULES_HOME}/bin/modulecmd" bash "$@")
}
export -f module
# Local Variables:
# mode: sh
# sh-basic-offset: 8
# tab-width: 8
# End: