core
This commit is contained in:
parent
d0bf0958c8
commit
4b2cc9a243
1 changed files with 29 additions and 23 deletions
52
sh/main.sh
52
sh/main.sh
|
@ -16,27 +16,10 @@ RWX_SHELL="$(cat "/proc/${$}/comm")"
|
||||||
|
|
||||||
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
|
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
|
||||||
|
|
||||||
# ╭──────────╮
|
|
||||||
# │ internal │
|
|
||||||
# ╰──────────╯
|
|
||||||
|
|
||||||
# _RWX_IFS
|
|
||||||
|
|
||||||
# ╭─────────╮
|
# ╭─────────╮
|
||||||
# │ private │
|
# │ private │
|
||||||
# ╰─────────╯
|
# ╰─────────╯
|
||||||
|
|
||||||
rwx_ifs_set() {
|
|
||||||
_RWX_IFS="${IFS}"
|
|
||||||
IFS="
|
|
||||||
"
|
|
||||||
}
|
|
||||||
|
|
||||||
rwx_ifs_unset() {
|
|
||||||
IFS="${_RWX_IFS}"
|
|
||||||
unset RWX_IFS
|
|
||||||
}
|
|
||||||
|
|
||||||
_rwx_main_log() {
|
_rwx_main_log() {
|
||||||
if rwx_shell_interactive; then
|
if rwx_shell_interactive; then
|
||||||
[ ${#} -gt 0 ] || set -- ""
|
[ ${#} -gt 0 ] || set -- ""
|
||||||
|
@ -70,6 +53,10 @@ rwx_shell_interactive() {
|
||||||
# │ core │
|
# │ core │
|
||||||
# ╰──────╯
|
# ╰──────╯
|
||||||
|
|
||||||
|
# ╭──────┬──────╮
|
||||||
|
# │ core │ find │
|
||||||
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
# find directory’s files by extension
|
# find directory’s files by extension
|
||||||
rwx_find_extension() {
|
rwx_find_extension() {
|
||||||
local extension="${1}"
|
local extension="${1}"
|
||||||
|
@ -93,7 +80,26 @@ rwx_find_shell() {
|
||||||
rwx_find_extension "sh" "${@}"
|
rwx_find_extension "sh" "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
rwx_main_source() {
|
# ╭──────┬─────╮
|
||||||
|
# │ core │ ifs │
|
||||||
|
# ╰──────┴─────╯
|
||||||
|
|
||||||
|
rwx_ifs_set() {
|
||||||
|
_RWX_IFS="${IFS}"
|
||||||
|
IFS="
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_ifs_unset() {
|
||||||
|
IFS="${_RWX_IFS}"
|
||||||
|
unset RWX_IFS
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭──────┬────────╮
|
||||||
|
# │ core │ source │
|
||||||
|
# ╰──────┴────────╯
|
||||||
|
|
||||||
|
rwx_source() {
|
||||||
local path="${1}"
|
local path="${1}"
|
||||||
[ -d "${path}" ] ||
|
[ -d "${path}" ] ||
|
||||||
return 1
|
return 1
|
||||||
|
@ -119,19 +125,19 @@ rwx_main_source() {
|
||||||
rwx_ifs_unset
|
rwx_ifs_unset
|
||||||
}
|
}
|
||||||
|
|
||||||
# ╭──────╮
|
# ╭──────┬──────╮
|
||||||
# │ main │
|
# │ core │ main │
|
||||||
# ╰──────╯
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
# run initial steps
|
# run initial steps
|
||||||
rwx_main() {
|
rwx_main() {
|
||||||
# system root
|
# system root
|
||||||
if ! rwx_main_source "${RWX_ROOT_SYSTEM}"; then
|
if ! rwx_source "${RWX_ROOT_SYSTEM}"; then
|
||||||
_rwx_main_log "Not a directory: ${RWX_ROOT_SYSTEM}"
|
_rwx_main_log "Not a directory: ${RWX_ROOT_SYSTEM}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# user root
|
# user root
|
||||||
rwx_main_source "${RWX_ROOT_USER}"
|
rwx_source "${RWX_ROOT_USER}"
|
||||||
# run interactive extras
|
# run interactive extras
|
||||||
if rwx_shell_interactive; then
|
if rwx_shell_interactive; then
|
||||||
# check format
|
# check format
|
||||||
|
|
Loading…
Reference in a new issue