#!/bin/zsh

############################################################################
# some sanity checks
#
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 zsh 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_DIR="${PMODULES_HOME}"


#############################################################################
# implement module comand as shell function
#
module() {
	eval $("${PMODULES_HOME}/bin/modulecmd" bash "$@")
}
export -f module

modbuild(){
	(
		eval $("${PMODULES_HOME}/bin/modulecmd" bash load System:bash)
		"${PMODULES_HOME}/bin/modbuild" "$@"
	)
}
export -f modbuild

# Local Variables:
# mode: sh
# sh-basic-offset: 8
# tab-width: 8
# End:
