2020-11-03 12:07:49 -08:00
|
|
|
#!/bin/bash
|
2020-11-13 10:25:04 -08:00
|
|
|
|
2022-02-20 12:44:29 -08:00
|
|
|
# PRIMARY SHELL LOAD SCRIPT - RUN FOR ALL INTERACTIVE SHELLS
|
2020-11-27 09:59:16 -08:00
|
|
|
|
2020-11-13 10:25:04 -08:00
|
|
|
# don't bother if bash is not the shell
|
|
|
|
[ ! "$SHELL" = "/bin/bash" ] && return 1
|
|
|
|
|
2022-02-20 12:44:29 -08:00
|
|
|
# ************ be sure module_load function is availABLE ***************************
|
2020-11-21 08:55:51 -08:00
|
|
|
[[ $(declare -F | grep module_load) ]] || source "$BASH_SHELL_BASE/module.lib"
|
2020-11-20 08:48:48 -08:00
|
|
|
|
2020-12-03 20:48:04 -08:00
|
|
|
module_load debug
|
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
echo "unable to load a 'debug' module using a noop for debug function"
|
|
|
|
# noop
|
|
|
|
function debug () {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
2022-02-20 12:44:29 -08:00
|
|
|
([[ $BASH_ENV ]] && [[ ! $- == *i* ]] && [[ $BASH_USE_ALIAS ]]) && shopt -s expand_aliases
|
2020-11-03 12:07:49 -08:00
|
|
|
|
|
|
|
# process the base directory by default
|
2020-11-13 10:25:04 -08:00
|
|
|
unset BASH_SHELL_BASE_LOADED
|
|
|
|
unset BASH_SHELL_LOADED
|
|
|
|
|
2022-02-20 12:44:29 -08:00
|
|
|
module_load shell-process-directory
|
2022-05-02 10:46:41 -07:00
|
|
|
|
|
|
|
if [[ $SSH_SESSION ]]; then
|
|
|
|
# ssh session only process base by default
|
|
|
|
# env | grep SSH
|
|
|
|
# echo ssh session bash load
|
|
|
|
# TODO process network dirs if environment variable is set
|
|
|
|
# process only base, nothing (i.e. BASH_SAFE_MODE, SSH_SHELL_CLEAN) if env variables are set
|
|
|
|
# see https://stackoverflow.com/a/59461195
|
|
|
|
shell_process_directory $BASH_SHELL_BASE
|
|
|
|
shell_process_directory $BASH_SHELL_ANY_HOST
|
|
|
|
shell_process_directory $BASH_SHELL_HOST
|
|
|
|
|
|
|
|
export BASH_SHELL_BASE_LOADED=true
|
|
|
|
|
|
|
|
else
|
|
|
|
# local shell so process all directories
|
|
|
|
for dir in ${1:-$BASH_SHELL_DIRS}; do
|
|
|
|
# env | grep BASH
|
|
|
|
# echo $dir
|
|
|
|
shell_process_directory $dir
|
|
|
|
[[ "$dir" = "$BASH_SHELL_BASE" ]] && export BASH_SHELL_BASE_LOADED=true
|
|
|
|
done
|
|
|
|
fi
|
2020-11-13 10:25:04 -08:00
|
|
|
|
|
|
|
export BASH_SHELL_LOADED=true
|
|
|
|
|
2022-02-20 12:44:29 -08:00
|
|
|
# Note: $HOME/shell or $HOME/BASH_SHELL_USER are processed via $HOME/.bashrc
|