2022-06-18 18:13:08 +00:00
|
|
|
|
# If not running interactively, don't do anything
|
2022-09-29 22:29:13 +00:00
|
|
|
|
SFP='.sz' # Script Family Prefix
|
|
|
|
|
[ -z ${DBG_SHRC} ] || echo "Entered ${SFP}.shrc"
|
2022-10-23 22:10:30 +00:00
|
|
|
|
export SHRC_D=~/${SFP}.shrc.d
|
|
|
|
|
unset SHLVL_${SFP##*.}
|
|
|
|
|
|
|
|
|
|
IS_INTERACTIVE=${IS_INTERACTIVE:-$-}
|
|
|
|
|
# himBHs - Interactive
|
|
|
|
|
# hBc - called with `bash -c`
|
|
|
|
|
# h Locate and remember (hash) commands as they are looked up for
|
|
|
|
|
# execution. This option is enabled by default.
|
|
|
|
|
# i Interactive shell.
|
|
|
|
|
# m Job control is enabled (see Job Control). All processes run in a
|
|
|
|
|
# separate process group. When a background job completes, the
|
|
|
|
|
# shell prints a line containing its exit status.
|
|
|
|
|
# c Commands were supplied from via `bash -c` command line switch.
|
|
|
|
|
# B The shell will perform brace expansion (see Brace Expansion).
|
|
|
|
|
# This option is on by default.
|
|
|
|
|
# H Enable ‘!’ style history substitution (see History Interaction).
|
|
|
|
|
# This option is on by default for interactive shells.
|
|
|
|
|
# s Read commands from the standard input.
|
|
|
|
|
|
|
|
|
|
case $IS_INTERACTIVE in
|
2022-06-18 18:13:08 +00:00
|
|
|
|
*i*) echo "Welcome $USER to $(hostname)";;
|
2022-10-23 22:10:30 +00:00
|
|
|
|
FORCE) ;;
|
2022-09-29 22:29:13 +00:00
|
|
|
|
*) return;;
|
2022-06-18 18:13:08 +00:00
|
|
|
|
esac
|
2022-10-23 22:10:30 +00:00
|
|
|
|
unset IS_INTERACTIVE
|
2022-06-18 18:13:08 +00:00
|
|
|
|
|
2022-09-29 22:29:13 +00:00
|
|
|
|
if [ -d ${SHRC_D} ]; then
|
|
|
|
|
script_source=("$(find ${SHRC_D} -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).pre")")
|
|
|
|
|
script_source+=("$(find ${SHRC_D} -maxdepth 0 -type d)")
|
|
|
|
|
script_source+=("$(find ${SHRC_D} -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).post")")
|
|
|
|
|
[ -z ${DBG_SHRC} ] || echo "Working with (${script_source[@]})..."
|
2022-06-18 18:13:08 +00:00
|
|
|
|
for script_src in ${script_source[@]}; do
|
2022-06-20 02:42:37 +00:00
|
|
|
|
scripts=($(find $script_src -maxdepth 1 -type f -not -name "*~" -not -name "*.off" -not -name "*.swp" | sort))
|
2022-09-29 22:29:13 +00:00
|
|
|
|
#[ -z ${DBG_SHRC} ] || echo "Within $script_src, will review (${scripts[@]})..."
|
2022-06-18 18:13:08 +00:00
|
|
|
|
for script_name in ${scripts[@]}; do
|
2022-09-29 22:29:13 +00:00
|
|
|
|
[ -z ${DBG_SHRC} ] || echo "Checking $script_name..."
|
2022-06-18 18:13:08 +00:00
|
|
|
|
if [ -r $script_name ]; then
|
2022-09-29 22:29:13 +00:00
|
|
|
|
[ -z ${DBG_SHRC} ] || echo "Sourcing $script_name..."
|
2022-06-18 18:13:08 +00:00
|
|
|
|
. $script_name
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
unset scripts
|
|
|
|
|
unset script_name
|
|
|
|
|
done
|
|
|
|
|
unset script_source
|
|
|
|
|
fi
|
|
|
|
|
|
2022-09-29 22:29:13 +00:00
|
|
|
|
[ -z ${DBG_SHRC} ] || echo "Exiting ${SFP}.shrc"
|