diff --git a/sh/main.sh b/sh/main.sh index bfa8c04..92edc7b 100644 --- a/sh/main.sh +++ b/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() {