main/file
This commit is contained in:
parent
b170098755
commit
3ffc60e4f1
1 changed files with 6 additions and 5 deletions
11
bash/main.sh
11
bash/main.sh
|
@ -12,21 +12,22 @@ function main_link_bashrc {
|
|||
|
||||
# import modules
|
||||
function main_import_modules {
|
||||
local root="${1}"
|
||||
if [ -d "${root}" ] ; then
|
||||
local file="${1}"
|
||||
if [ -f "${file}" ] ; then
|
||||
local root="$(dirname "${file}")"
|
||||
local IFS=$'\n'
|
||||
local modules=($(find "${root}" -type 'f' -name '*.sh'))
|
||||
local module
|
||||
for module in "${modules[@]}" ; do
|
||||
if [ "${module}" != "${MAIN_BASH_FILE}" ] ; then
|
||||
if [ "${module}" != "${file}" ] ; then
|
||||
source "${module}"
|
||||
fi
|
||||
done
|
||||
log_trace "${modules[@]}"
|
||||
else
|
||||
log_fatal "No directory: ${root}"
|
||||
log_fatal "No file: ${file}"
|
||||
fi
|
||||
}
|
||||
|
||||
# import modules
|
||||
main_import_modules "${MAIN_BASH_ROOT}"
|
||||
main_import_modules "${MAIN_BASH_FILE}"
|
||||
|
|
Loading…
Reference in a new issue