Commit aba087f8 authored by gsell's avatar gsell
Browse files

scripts/Bootstrap/Pmodules

- do not read profiles
- tcsh output added to 'export_env()'
- supress errors from 'typeset' in 'save_env()'
- use 'export_env()' to instead of 'echo'
- add global declaration of PMODULES_DEFAULT_GROUPS
  and PMODULES_DEFAULT_RELEASES to 'pmodules_init()'
- add 'tcsh' as supported shell
parent fde9205f
#!@PMODULES_HOME@/bin/bash
#!@PMODULES_HOME@/bin/bash --noprofile --norc
#
#set -o nounset
......@@ -31,21 +31,33 @@ shopt -s nullglob
declare -a Groups='()'
declare -A HierarchyDepths='()'
save_env() {
export_env() {
local s=''
while (( $# > 0 )); do
s+="$( typeset -p $1 );"
shift
done
echo export PMODULES_ENV=$( "${PMODULES_HOME}/bin/base64" --wrap=0 <<< "$s" )
if [[ "${shell}" == "bash" ]]; then
while (( $# > 0 )); do
echo -n "export $1=\"${!1}\";"
shift
done
return
elif [[ "${shell}" == "tcsh" ]]; then
while (( $# > 0 )); do
echo "setenv $1 ${!1}"
shift
done
return
fi
}
export_env() {
save_env() {
local s=''
local tmp
while (( $# > 0 )); do
echo -n "export $1=${!1};"
tmp="$( typeset -p $1 2> /dev/null)"
[[ -n "${tmp}" ]] && s+="${tmp};"
shift
done
declare -g PMODULES_ENV=$( "${PMODULES_HOME}/bin/base64" --wrap=0 <<< "$s" )
export_env PMODULES_ENV
}
trap 'save_env Groups HierarchyDepths UsedReleases PMODULES_DEFAULT_GROUPS PMODULES_DEFINED_RELEASES PMODULES_DEFAULT_RELEASES' EXIT
......@@ -1054,7 +1066,9 @@ subcommand_use() {
fi
shift
done
echo "export PMODULES_USED_GROUPS=${PMODULES_USED_GROUPS}"
#echo "export PMODULES_USED_GROUPS=${PMODULES_USED_GROUPS}"
declare -g PMODULES_USED_GROUPS="${PMODULES_USED_GROUPS}"
export_env PMODULES_USED_GROUPS
[[ ${#dirs_to_add[@]} == 0 ]] && return
for dir in "${dirs_to_add[@]}"; do
......@@ -1112,7 +1126,9 @@ subcommand_unuse() {
fi
shift
done
echo "export PMODULES_USED_GROUPS=${PMODULES_USED_GROUPS}"
#echo "export PMODULES_USED_GROUPS=${PMODULES_USED_GROUPS}"
declare -g PMODULES_USED_GROUPS="${PMODULES_USED_GROUPS}"
export_env PMODULES_USED_GROUPS
[[ ${#dirs_to_remove[@]} == 0 ]] && return
for dir in "${dirs_to_remove[@]}"; do
subcommand_generic1 unuse "${dir}"
......@@ -1179,12 +1195,16 @@ subcommand_list() {
}
pmodules_init() {
declare -g PMODULES_DEFAULT_GROUPS=''
declare -g PMODULES_DEFAULT_RELEASES=''
source "${PMODULES_ROOT}/${PMODULES_CONFIG_DIR}/environment.bash"
declare -g LOADEDMODULES=''
declare -g PMODULES_USED_GROUPS=''
declare -g MODULEPATH=''
declare -g _LMFILES_=''
for group in ${PMODULES_DEFAULT_GROUPS}; do
append_path MODULEPATH "${PMODULES_ROOT}/${group}/${PMODULES_MODULEFILES_DIR}"
append_path PMODULES_USED_GROUPS "${group}"
......@@ -1479,6 +1499,9 @@ case $1 in
bash )
declare shell="$1"
;;
tcsh )
declare shell="$1"
;;
* )
die 1 "${CMD}: unsupported shell -- $1"
;;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment