load only base and any host when coming from ssh
parent
1778ddca3e
commit
9d7e07a113
28
load.sh
28
load.sh
|
@ -24,11 +24,29 @@ unset BASH_SHELL_BASE_LOADED
|
||||||
unset BASH_SHELL_LOADED
|
unset BASH_SHELL_LOADED
|
||||||
|
|
||||||
module_load shell-process-directory
|
module_load shell-process-directory
|
||||||
for dir in ${1:-$BASH_SHELL_DIRS}; do
|
|
||||||
# echo $dir $BASH_SHELL_BASE
|
if [[ $SSH_SESSION ]]; then
|
||||||
shell_process_directory $dir
|
# ssh session only process base by default
|
||||||
[[ "$dir" = "$BASH_SHELL_BASE" ]] && export BASH_SHELL_BASE_LOADED=true
|
# env | grep SSH
|
||||||
done
|
# 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
|
||||||
|
|
||||||
export BASH_SHELL_LOADED=true
|
export BASH_SHELL_LOADED=true
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ function shell_process_directory () {
|
||||||
|
|
||||||
|
|
||||||
DIR=${1:-$BASH_SHELL_BASE}
|
DIR=${1:-$BASH_SHELL_BASE}
|
||||||
# echo soucring directory $DIR
|
# echo sourcing directory $DIR
|
||||||
# if [[ $DIR = "$BASH_SHELL_BASE" ]]; then
|
# if [[ $DIR = "$BASH_SHELL_BASE" ]]; then
|
||||||
# BASH_SHELL_IGNORE=$(shell_get_ignores)
|
# BASH_SHELL_IGNORE=$(shell_get_ignores)
|
||||||
# excludes=$BASH_SHELL_IGNORE
|
# excludes=$BASH_SHELL_IGNORE
|
||||||
|
@ -41,6 +41,8 @@ function shell_process_directory () {
|
||||||
SUBDIRS=$([[ -f "$DIR/.bash-shell-include" ]] && cat "$DIR/.bash-shell-include" || cat "$BASH_SHELL_BASE/.bash-shell-include")
|
SUBDIRS=$([[ -f "$DIR/.bash-shell-include" ]] && cat "$DIR/.bash-shell-include" || cat "$BASH_SHELL_BASE/.bash-shell-include")
|
||||||
[[ $SSH_SESSION ]] && SUBDIRS+=" ssh/session"
|
[[ $SSH_SESSION ]] && SUBDIRS+=" ssh/session"
|
||||||
IGNORE_FILE="$([[ -f "$DIR/.bash-shell-ignore" ]] && echo "$DIR" || echo "$BASH_SHELL_BASE")/.bash-shell-ignore"
|
IGNORE_FILE="$([[ -f "$DIR/.bash-shell-ignore" ]] && echo "$DIR" || echo "$BASH_SHELL_BASE")/.bash-shell-ignore"
|
||||||
|
# echo $DIR
|
||||||
|
# echo $SUBDIRS
|
||||||
for SUBDIR in $SUBDIRS; do
|
for SUBDIR in $SUBDIRS; do
|
||||||
if [ -e "$DIR/$SUBDIR" ]; then
|
if [ -e "$DIR/$SUBDIR" ]; then
|
||||||
# echo processing subdirectory $DIR/$SUBDIR
|
# echo processing subdirectory $DIR/$SUBDIR
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
|
|
||||||
if ( [[ $SHELL_INTERACTIVE ]] );then
|
if ( [[ $SHELL_INTERACTIVE ]] );then
|
||||||
if ( [[ $BASH_SHELL_BASE_LOADED = true ]] ) ; then
|
if ( [[ $BASH_SHELL_BASE_LOADED = true ]] ) ; then
|
||||||
# echo loading user shell sources
|
|
||||||
export BASH_SHELL_USER=${BASH_SHELL_USER:-"shell"}
|
export BASH_SHELL_USER=${BASH_SHELL_USER:-"shell"}
|
||||||
|
# echo loading user $USER shell at $HOME/$BASH_SHELL_USER
|
||||||
[[ -d $HOME/$BASH_SHELL_USER ]] && shell_process_directory "$HOME/$BASH_SHELL_USER" ||\
|
[[ -d $HOME/$BASH_SHELL_USER ]] && shell_process_directory "$HOME/$BASH_SHELL_USER" ||\
|
||||||
echo no user shell directory $HOME/$BASH_SHELL_USER to process, create one or clone a template
|
echo no user shell directory $HOME/$BASH_SHELL_USER to process, create one or clone a template
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue