diff --git a/Pmodules/bash b/Pmodules/bash index 075aabb..4c4bb0c 100644 --- a/Pmodules/bash +++ b/Pmodules/bash @@ -5,7 +5,7 @@ # if [ ${BASH_VERSINFO:-0} -lt 3 ]; then echo "BASH version ${BASH_VERSION} ist not supported! You need at least version 3..." - return + return 1 fi ############################################################################# @@ -60,12 +60,12 @@ export -f module # helper functions # std::append_path () { - local -r P=$1 - local -r d=$2 + local -r P="$1" + local -r d="$2" if ! echo ${!P} | egrep -q "(^|:)${d}($|:)" ; then if [[ -z ${!P} ]]; then - eval $P=${d} + eval $P="${d}" else eval $P="${!P}:${d}" fi @@ -90,9 +90,9 @@ std::append_path () { # https://stackoverflow.com/questions/273909/how-do-i-manipulate-path-elements-in-shell-scripts # std::replace_path () { - local -r path=$1 - local -r removepat=$2 - local -r replacestr=$3 + local -r path="$1" + local -r removepat="$2" + local -r replacestr="$3" local -r removestr=$(echo "${!path}" | tr ":" "\n" | grep -m 1 "^$removepat\$") export $path=$(echo "${!path}" | tr ":" "\n" | sed "s:^${removestr}\$:${replacestr}:" | @@ -108,7 +108,17 @@ save_env() { echo export PMODULES_ENV=$( "${PMODULES_HOME}/sbin/base64" --wrap=0 <<< "$s" ) } -#module purge +############################################################################ +# 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 ############################################################################# # setup environment diff --git a/Pmodules/profile.bash.in b/Pmodules/profile.bash.in index c0fdbe9..1910f76 100644 --- a/Pmodules/profile.bash.in +++ b/Pmodules/profile.bash.in @@ -7,10 +7,6 @@ # ${PMODULES_ROOT}/Tools/Pmodules/${PMODULES_VERSION} # -declare -x PMODULES_DEFAULT_GROUPS -declare -x PMODULES_DEFAULT_RELEASES -declare -x PMODULES_VERSION - : ${PMODULES_DEFAULT_GROUPS:='Tools Programming'} : ${PMODULES_DEFAULT_RELEASES:='stable'} : ${PMODULES_VERSION:=@PMODULES_VERSION@} @@ -19,6 +15,10 @@ declare -x PMODULES_VERSION # N O C H A N G E S B E L O W T H I S L I N E ! # ############################################################################# +export PMODULES_DEFAULT_GROUPS +export PMODULES_DEFAULT_RELEASES +export PMODULES_VERSION + declare -x PMODULES_MODULEFILES_DIR='modulefiles' declare -x PMODULES_DEFINED_RELEASES=':unstable:stable:deprecated:' @@ -27,29 +27,12 @@ declare -x PMODULES_CONFIG_DIR=$(basename $(cd $(dirname "${BASH_SOURCE}") && pw declare -x PMODULES_HOME="${PMODULES_ROOT}/Tools/Pmodules/${PMODULES_VERSION}" declare -x PMODULES_DIR="${PMODULES_HOME}" -############################################################################ -# 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 +test -r "${PMODULES_HOME}/init/bash" && source "$_" -############################################################################ -# inititialize Pmodules for bash -# -_init_bash="${PMODULES_HOME}/init/bash" -if [[ ! -r "${_init_bash}" ]]; then - echo "Oops: cannot initialize Modules!" - echo "${_init_bash}: File does not exist or is not readable." +if [[ $? != 0 ]]; then + echo "Oops: cannot initialize Pmodules!" return 1 fi -source "${_init_bash}" -unset _init_bash # Local Variables: # mode: sh