main/file

This commit is contained in:
Marc Beninca 2023-05-15 18:41:02 +02:00
parent b170098755
commit 3ffc60e4f1

View file

@ -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}"