diff --git a/function/01-basic b/function/01-basic index 3e121ea..b81f2f7 100644 --- a/function/01-basic +++ b/function/01-basic @@ -21,7 +21,7 @@ function function_list() { done echo "${FUNCS[@]}" else - cp# will list all sourced/declared functions available + # will list all sourced/declared functions available echo echo -e "\033[1;4;32m""Functions:""\033[0;34m" declare -F | grep -v "declare -f\s_" | awk {'print $3'} diff --git a/load.sh b/load.sh index 00f19d3..7dc3d1a 100755 --- a/load.sh +++ b/load.sh @@ -1,5 +1,15 @@ #!/bin/bash +# [[ ! $- == *i* ]] && exec >> ~/logs/load.log && exec 2>&1 + +function nilog () { + [[ ! $- == *i* ]] && echo -e "-----\n $USER $*" &>> ~/logs/load.log +} + +nilog "called load.sh $(date)" +# nilog caller: $(caller) +# nilog pid: $(ps -o comm= $PPID) + # don't bother if bash is not the shell [ ! "$SHELL" = "/bin/bash" ] && return 1 @@ -18,6 +28,8 @@ DIR=${1:-$(dirname ${BASH_SOURCE[0]})} module_load file [[ $? -ne 0 ]] && echo unable to access the file module, aboarting load && return 1 +([[ $BASH_ENV ]] && [[ ! $- == *i* ]] && [[ $BASH_USE_ALIAS ]]) && shopt -s expand_aliases + function shell_process_directory () { local SUBDIRS local DIR @@ -53,11 +65,10 @@ function shell_process_directory () { local SUBDIRS local IGNORE_FILE SUBDIRS=$([[ -f "$DIR/.bash-shell-include" ]] && cat "$DIR/.bash-shell-include" || echo $BASH_SHELL_BASE_SUBDIRS) - [[ $SSH_LOGIN ]] && SUBDIRS+=" ssh" + [[ $SSH_SESSION ]] && SUBDIRS+=" ssh" IGNORE_FILE="$([[ -f "$DIR/.bash-shell-ignore" ]] && echo "$DIR" || echo "$BASH_SHELL_BASE")/.bash-shell-ignore" for SUBDIR in $SUBDIRS; do if [ -e "$DIR/$SUBDIR" ]; then - # echo processing subdirectory $DIR/$SUBDIR # must quote all globs to avoid bash glob expansion which is likely on # TODO have default set of ignores plus check for .shell-ignore diff --git a/setup/etc/bash.bashrc b/setup/etc/bash.bashrc index e606959..d174f41 100644 --- a/setup/etc/bash.bashrc +++ b/setup/etc/bash.bashrc @@ -11,5 +11,4 @@ if ([ -n "$SSH_CONNECTION" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]); then export SSH_SESSION=true source /etc/profile fi -shopt -s expand_aliases source $BASH_SHELL_LOAD diff --git a/shell.env b/shell.env index df86111..f4960a4 100644 --- a/shell.env +++ b/shell.env @@ -33,7 +33,13 @@ export BASH_SHELL_LOAD=$BASH_SHELL_BASE/load.sh # load.sh is default export BASH_SHELL_STARTUP=$BASH_SHELL_BASE/startup.sh # strtup.sh is default # if uncommented next line sets up implicit sourcing for non-interactive shells -# export BASH_ENV=$BASH_SHELL_LOAD # use base repo +# echo ----NON_INTERACTIVE SHELL INFO----- +# echo enabling bash shell repos for non-inactive shell +export BASH_ENV=$BASH_SHELL_LOAD # use base repo +# echo enabling aliases with non-interactive shell +export BASH_USE_ALIAS=true # will source aliases for non-interactive +# echo see $BASH_SHELL_BASE/shell.env +# echo --------- # if not using implicit sourcing for non-interactive shells then on can do this per script ################## # expanding aliases is optional @@ -43,6 +49,7 @@ export BASH_SHELL_STARTUP=$BASH_SHELL_BASE/startup.sh # strtup.sh is default # shopt -u expand_aliases #################### +# set ssh session if non-interactive only ([ -n "$SSH_CONNECTION" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]) && export SSH_SESSION=true # identify a network name that this host resides on