diff --git a/sh/main.sh b/sh/main.sh index 8d950b0..75036ef 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,4 +1,5 @@ #! /usr/bin/env sh +# main module # ╭──────╮ # │ main │ @@ -8,6 +9,7 @@ # │ main │ constants │ # ╰──────┴───────────╯ +# name of the entrypoint file RWX_MAIN_NAME="main.sh" RWX_SELF_NAME="rwx" @@ -61,44 +63,20 @@ rwx_main() { # │ main │ cache │ # ╰──────┴───────╯ +RWX_CODE="" + +# cache source code of a module rwx_cache() { local root="${1}" local module="${2}" local name="${module%.sh}" local path="${root}/${module}" - local fill text - fill="$(rwx_fill "${#name}" ─)" + local text text="$(cat "${path}")" - case "${text}" in - "#!"*) - RWX_CODE="${text} - -# ╭───┬────┬─${fill}─╮ -# │ ↖ │ sh │ ${name} │ -# ╰───┴────┴─${fill}─╯" - ;; - *) - RWX_CODE="${RWX_CODE} - -# ╭───┬────┬─${fill}─╮ -# │ ↙ │ sh │ ${name} │ -# ╰───┴────┴─${fill}─╯ - -${text}" - ;; - esac -} - -# ╭──────┬──────╮ -# │ main │ fill │ -# ╰──────┴──────╯ - -rwx_fill() { - local index="${1}" - while [ "${index}" -gt 0 ]; do - printf "%s" "${2}" - index=$((index - 1)) - done + RWX_CODE="${RWX_CODE}\ +#↓ ${name} +${text} +" } # ╭──────┬────────╮ @@ -115,16 +93,17 @@ rwx_source() { count=0 __rwx_log "" \ ". ${root}" - rwx_ifs_set - for module in $(rwx_find_shell "${root}" "${file}"); do + local modules="$(rwx_find_shell "${root}" "${file}")" + while IFS= read -r module; do count=$((count + 1)) __rwx_log "$(printf "%02d" "${count}") ${module%.sh}" # shellcheck disable=SC1090 . "${root}/${module}" # cache code rwx_cache "${root}" "${module}" - done - rwx_ifs_unset + done <