main/if
This commit is contained in:
parent
62b8f60841
commit
678cf741c9
1 changed files with 23 additions and 24 deletions
47
sh/main.sh
47
sh/main.sh
|
@ -63,33 +63,32 @@ _sh_main_log() {
|
|||
|
||||
main_source_directory() {
|
||||
local path="${1}"
|
||||
if [ -d "${path}" ]; then
|
||||
local cmd count ifs module modules
|
||||
modules="$(sh_source_find "${path}" "${SH_MAIN_NAME}")"
|
||||
ifs="${IFS}"
|
||||
IFS="
|
||||
"
|
||||
count=0
|
||||
_sh_main_log "" \
|
||||
". ${path}"
|
||||
for module in ${modules}; do
|
||||
count=$((count + 1))
|
||||
_sh_main_log "$(printf "%02d" "${count}") ${module%.sh}"
|
||||
module="${path}/${module}"
|
||||
# shellcheck disable=SC1090
|
||||
. "${module}"
|
||||
cmd="$(_sh_main_commands "${module}")"
|
||||
if [ -n "${cmd}" ]; then
|
||||
[ -n "${CMD}" ] && CMD="${CMD}
|
||||
"
|
||||
CMD="${CMD}${cmd}"
|
||||
fi
|
||||
done
|
||||
IFS="${ifs}"
|
||||
else
|
||||
if [ ! -d "${path}" ]; then
|
||||
_sh_main_log "Not a directory: ${path}"
|
||||
return 1
|
||||
fi
|
||||
local cmd count ifs module modules
|
||||
modules="$(sh_source_find "${path}" "${SH_MAIN_NAME}")"
|
||||
ifs="${IFS}"
|
||||
IFS="
|
||||
"
|
||||
count=0
|
||||
_sh_main_log "" \
|
||||
". ${path}"
|
||||
for module in ${modules}; do
|
||||
count=$((count + 1))
|
||||
_sh_main_log "$(printf "%02d" "${count}") ${module%.sh}"
|
||||
module="${path}/${module}"
|
||||
# shellcheck disable=SC1090
|
||||
. "${module}"
|
||||
cmd="$(_sh_main_commands "${module}")"
|
||||
if [ -n "${cmd}" ]; then
|
||||
[ -n "${CMD}" ] && CMD="${CMD}
|
||||
"
|
||||
CMD="${CMD}${cmd}"
|
||||
fi
|
||||
done
|
||||
IFS="${ifs}"
|
||||
}
|
||||
|
||||
main_source_file() {
|
||||
|
|
Loading…
Reference in a new issue