Compare commits

...

9 commits

Author SHA1 Message Date
2a9169947e
root/shrink
All checks were successful
/ job (push) Successful in 4m28s
2025-07-03 22:18:02 +02:00
bb8bedae27
lint/fill,text 2025-07-03 21:47:57 +02:00
2a6bfab4f9
user_id 2025-07-03 21:45:15 +02:00
72200668a9
sh/main 2025-07-03 21:38:36 +02:00
12561ee505
.sh 2025-07-03 21:32:52 +02:00
94689a23bf
cache/fill 2025-07-03 21:27:44 +02:00
8c55351aae
cache/wip 2025-07-03 21:11:39 +02:00
ebc41e8a53
source/file 2025-07-03 20:42:59 +02:00
706847f746
source/root 2025-07-03 18:14:56 +02:00
2 changed files with 58 additions and 12 deletions

View file

@ -37,8 +37,10 @@ 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}"; then
if ! rwx_source "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}"; then
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
return 1
fi
@ -53,26 +55,72 @@ rwx_main() {
fi
}
# ╭──────┬───────╮
# │ main │ cache │
# ╰──────┴───────╯
rwx_cache() {
local root="${1}"
local module="${2}"
local name="${module%.sh}"
local path="${root}/${module}"
local fill text
fill="$(rwx_fill "${#name}")"
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
}
# ╭──────┬────────╮
# │ main │ source │
# ╰──────┴────────╯
# source code from file path
rwx_source() {
local path="${1}"
[ -d "${path}" ] ||
local root="${1}"
[ -d "${root}" ] ||
return 1
local file="${2}"
local count module
count=0
__rwx_log "" \
". ${path}"
". ${root}"
rwx_ifs_set
for module in $(rwx_find_shell "${path}" "${RWX_MAIN_NAME}"); do
for module in $(rwx_find_shell "${root}" "${file}"); do
count=$((count + 1))
__rwx_log "$(printf "%02d" "${count}") ${module%.sh}"
module="${path}/${module}"
# shellcheck disable=SC1090
. "${module}"
. "${root}/${module}"
# cache code
rwx_cache "${root}" "${module}"
done
rwx_ifs_unset
}

View file

@ -49,11 +49,9 @@ rwx_remove() {
}
rwx_root() {
if [ "$(id --user)" -eq 0 ]; then
return 0
else
return 1
fi
local user_id
user_id="$(id --user)"
[ "${user_id}" -eq 0 ] || return 1
}
rwx_warn_wipe() {