From 8c55351aaecb2f915613021ad22a9820c3207116 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 3 Jul 2025 21:11:39 +0200 Subject: [PATCH] cache/wip --- sh/main.sh | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index ed795fc..81c65cd 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -37,6 +37,8 @@ RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" # run initial steps rwx_main() { + # cache main + rwx_cache "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}" # source system root if ! rwx_source "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}"; then __rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}" @@ -53,6 +55,28 @@ rwx_main() { fi } +# ╭──────┬───────╮ +# │ main │ cache │ +# ╰──────┴───────╯ + +rwx_cache() { + local root="${1}" + local module="${2}" + local name="${module%.sh}" + local path="${root}/${module}" + local text="$(cat "${path}")" + case "${text}" in + "#!"*) RWX_CODE="${text}" ;; + *) RWX_CODE="${RWX_CODE} + +# ╭╮ +# │ ${name} │ +# ╰╯ + +${text}" ;; + esac +} + # ╭──────┬────────╮ # │ main │ source │ # ╰──────┴────────╯ @@ -71,9 +95,10 @@ rwx_source() { for module in $(rwx_find_shell "${root}" "${file}"); do count=$((count + 1)) __rwx_log "$(printf "%02d" "${count}") ${module%.sh}" - module="${root}/${module}" # shellcheck disable=SC1090 - . "${module}" + . "${root}/${module}" + # cache code + rwx_cache "${root}" "${module}" done rwx_ifs_unset }