shell-base/startup.sh

32 lines
784 B
Bash
Executable File

#!/bin/bash
function startup_load () {
local SDIRS
local SDIR
local DIRS
[[ $1 ]] && DIRS=("$1") || DIRS=("${BASH_SHELL_DIRS}")
llog "startup directories to try ${DIRS[*]}"
SDIRS=()
j=0
cnt=${#DIRS[@]}
for ((i=0;i<cnt;i++)); do
DIR="${DIRS[i]}/startup"
[ -d $DIR ] && SDIRS[j]=$DIR && j+=1
done
# STARTUP_DIRS is array of any other startup directores where scripts may be loaded from
[ $STARTUP_DIRS ] && SDIRS=("$STARTUP_DIRS" "${SDIRS[@]}")
# echo -e "Statup Directories to source \n ${SDIRS[@]} \n"
source $BASH_SHELL_BASE/source-dir.func
for SDIR in "${SDIRS[@]}"
do
llog "startup dir to source $SDIR"
source_dir -p "archive" -x '"*.off" "*.md"' -d 0 $SDIR
done
}
# if script was executed then call the function
(return 0 2>/dev/null) || startup_load