From fd3528c3ec37ed0a5b69c3020005d1d7bd590f02 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 02:27:02 +0200 Subject: [PATCH 01/19] crypt/setup --- sh/cryptsetup.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sh/cryptsetup.sh b/sh/cryptsetup.sh index fd20a64..28e4de3 100644 --- a/sh/cryptsetup.sh +++ b/sh/cryptsetup.sh @@ -1,8 +1,18 @@ -_rwx_cmd_cs() { rwx_crypt "${@}"; } +# ╭───────╮ +# │ crypt │ +# ╰───────╯ + +# ╭───────┬───────────╮ +# │ crypt │ constants │ +# ╰───────┴───────────╯ RWX_CRYPT_ROOT="/data/home/user/crypt" RWX_CRYPT_VAR="/var/lib/crypt" +# ╭───────┬───────────╮ +# │ crypt │ functions │ +# ╰───────┴───────────╯ + rwx_crypt_device() { local device size local index=0 @@ -25,7 +35,8 @@ rwx_crypt_device() { fi } -rwx_crypt() { +#/ cs +rwx_crypt_setup() { local action="${1}" local action_close="close" local action_open="open" From 07b0c3fa050e619f9857aee3aec65934732f860e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 02:47:38 +0200 Subject: [PATCH 02/19] crypt --- sh/{cryptsetup.sh => crypt.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sh/{cryptsetup.sh => crypt.sh} (100%) diff --git a/sh/cryptsetup.sh b/sh/crypt.sh similarity index 100% rename from sh/cryptsetup.sh rename to sh/crypt.sh From 8ff5111c0e2913344657226ad6026d5a0d446e26 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 03:30:26 +0200 Subject: [PATCH 03/19] readme/tasks --- readme.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 532211c..5ca0cd3 100644 --- a/readme.md +++ b/readme.md @@ -115,7 +115,15 @@ Two interpreted languages for flexibility. * ffmpeg * tmux * get unresolved path for new panes & windows -* fully working doc function algorithm -* self install aliases +* source code + * doc parsing algorithm + * install commands + * handle dependencies + * binaries + * modules + * handle tasks + * readme.md / when + * FIXME + * TODO ### 6.2 [Further tasks](#when) {#when-further} From 34881bb0151db3318510915d4ddad8bef337f460 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 03:40:08 +0200 Subject: [PATCH 04/19] main/| --- sh/main.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 62a5bfc..f9241ac 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -42,8 +42,8 @@ RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" # ╰──────┴──────╯ # find directory’s files by extension -#> find -#> sort +#| find +#| sort rwx_find_extension() { local extension="${1}" local root="${2}" @@ -125,7 +125,7 @@ EOF # cache source code of a module # inside a global code variable -#> cat +#| cat rwx_cache() { local root="${1}" local module="${2}" From 6332717fa3163029d2a987b2d0606281591f87ea Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 03:47:21 +0200 Subject: [PATCH 05/19] crypt/| --- sh/crypt.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sh/crypt.sh b/sh/crypt.sh index 28e4de3..c493adf 100644 --- a/sh/crypt.sh +++ b/sh/crypt.sh @@ -6,6 +6,7 @@ # │ crypt │ constants │ # ╰───────┴───────────╯ +# TODO variablize RWX_CRYPT_ROOT="/data/home/user/crypt" RWX_CRYPT_VAR="/var/lib/crypt" @@ -13,6 +14,7 @@ RWX_CRYPT_VAR="/var/lib/crypt" # │ crypt │ functions │ # ╰───────┴───────────╯ +#| cat rwx_crypt_device() { local device size local index=0 @@ -35,6 +37,15 @@ rwx_crypt_device() { fi } +#| id +#| mkdir +#| qemu-nbd +#| cryptsetup +#| mount +#| umount +#| rmdir +#| cat +#| rm #/ cs rwx_crypt_setup() { local action="${1}" From a54f0a82f7286d82e295debacc6fb49b18ef8f4e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 03:58:17 +0200 Subject: [PATCH 06/19] commands/ffmpeg,tmux --- sh/ffmpeg.sh | 6 +++++- sh/tmux.sh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sh/ffmpeg.sh b/sh/ffmpeg.sh index c32ad06..529d6ba 100644 --- a/sh/ffmpeg.sh +++ b/sh/ffmpeg.sh @@ -1,8 +1,12 @@ +# ╭────────╮ +# │ ffmpeg │ +# ╰────────╯ + # ╭────────┬─────────┬───────╮ # │ ffmpeg │ devices │ reset │ # ╰────────┴─────────┴───────╯ -_rwx_cmd_rwx_ffmpeg_devices_reset() { rwx_ffmpeg_devices_reset "${@}"; } +#/ rwx_ffmpeg_devices_reset rwx_ffmpeg_devices_reset() { local module="uvcvideo" modprobe --remove "${module}" && diff --git a/sh/tmux.sh b/sh/tmux.sh index 9213e01..bd72c21 100644 --- a/sh/tmux.sh +++ b/sh/tmux.sh @@ -36,7 +36,7 @@ rwx_tmux_list() { # │ tmux │ setup │ # ╰──────┴───────╯ -_rwx_cmd_rwx_tmux_setup() { rwx_tmux_setup "${@}"; } +#/ rwx_tmux_setup rwx_tmux_setup() { local file script if rwx_root; then From 389f73a0b93485e810c07965ed3c97d2201e8093 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 04:27:22 +0200 Subject: [PATCH 07/19] readme/tasks --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index 5ca0cd3..e78c221 100644 --- a/readme.md +++ b/readme.md @@ -118,6 +118,10 @@ Two interpreted languages for flexibility. * source code * doc parsing algorithm * install commands + * remove existing before + * test required + * binaries + * modules * handle dependencies * binaries * modules From d9a6e334093580736f37524c8c70aefa9560f8cb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 04:35:32 +0200 Subject: [PATCH 08/19] code/main --- sh/code.sh | 31 +++++++++++++++++++++++++++++++ sh/main.sh | 37 ++++--------------------------------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/sh/code.sh b/sh/code.sh index de4b331..7eede91 100644 --- a/sh/code.sh +++ b/sh/code.sh @@ -181,3 +181,34 @@ rwx_code_parse() { --assign action="${action}" \ "${_rwx_code_awk}" } + +# ╭──────┬──────╮ +# │ code │ main │ +# ╰──────┴──────╯ + +rwx_code_main() { + # source user root + rwx_source "${RWX_SELF_USER}" + # load code cache + rwx_code_load + # context / command + local command + # command name used to run + # (stripped from hyphen interactive flag) + command="$(basename "${0}" | sed "s|^-||")" + case "${command}" in + "bash" | "dash" | "sh") unset command ;; + *) ;; + esac + if [ -n "${command}" ]; then + local function + # find the matching function + function="$(rwx_code_alias_function "${command}")" + if [ -n "${function}" ]; then + "${function}" "${@}" + fi + # context / shell + else + rwx_self_init + fi +} diff --git a/sh/main.sh b/sh/main.sh index f9241ac..d75515f 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -3,15 +3,6 @@ # │ main │ # ╰──────╯ # main module -# * builtins -# * echo -# * printf -# * read -# * binaries -# * awk -# * cat -# * find -# * sed # ╭──────┬───────────╮ # │ main │ constants │ @@ -29,6 +20,7 @@ RWX_SELF_NAME="rwx" # cache of all sourced code modules _rwx_code="" +# TODO variablize # system root directory of the project RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" # user root directory of the project @@ -145,6 +137,7 @@ ${text} # ╰──────┴──────╯ # run initial steps +#< code rwx_main() { # cache main rwx_cache "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}" @@ -153,30 +146,8 @@ rwx_main() { __rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}" return 1 fi - # source user root - rwx_source "${RWX_SELF_USER}" - # load code cache - rwx_code_load - # context / command - local command - # command name used to run - # (stripped from hyphen interactive flag) - command="$(basename "${0}" | sed "s|^-||")" - case "${command}" in - "bash" | "dash" | "sh") unset command ;; - *) ;; - esac - if [ -n "${command}" ]; then - local function - # find the matching function - function="$(rwx_code_alias_function "${command}")" - if [ -n "${function}" ]; then - "${function}" "${@}" - fi - # context / shell - else - rwx_self_init - fi + # run code main function + rwx_code_main } # ╭──────┬─────╮ From 4f53472768047234da6d95de16c5da2a91a11163 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 04:44:46 +0200 Subject: [PATCH 09/19] code/user --- sh/code.sh | 4 ++++ sh/main.sh | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sh/code.sh b/sh/code.sh index 7eede91..d6ff778 100644 --- a/sh/code.sh +++ b/sh/code.sh @@ -6,6 +6,10 @@ # │ code │ variables │ # ╰──────┴───────────╯ +# TODO variablize +# user root directory of the project +RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" + # cache for the parsing awk script _rwx_code_awk="$(cat "${RWX_ROOT_SYSTEM}/code.awk")" # cache for code aliases diff --git a/sh/main.sh b/sh/main.sh index d75515f..881c2fa 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -23,8 +23,6 @@ _rwx_code="" # TODO variablize # system root directory of the project RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" -# user root directory of the project -RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" # path to the entrypoint main file of the project RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" From 820ec05b13eff1a8390cead48313e79a4d4b4f40 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 05:00:09 +0200 Subject: [PATCH 10/19] code/main --- sh/code.sh | 2 ++ sh/main.sh | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sh/code.sh b/sh/code.sh index d6ff778..8e59a9e 100644 --- a/sh/code.sh +++ b/sh/code.sh @@ -7,6 +7,8 @@ # ╰──────┴───────────╯ # TODO variablize +# path to the entrypoint main file of the project +RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" # user root directory of the project RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" diff --git a/sh/main.sh b/sh/main.sh index 881c2fa..be954c5 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -24,9 +24,6 @@ _rwx_code="" # system root directory of the project RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" -# path to the entrypoint main file of the project -RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" - # ╭──────┬──────╮ # │ main │ find │ # ╰──────┴──────╯ From 1345f07e163ee5ca42f6dc43f59b18d0a64aacd4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 05:50:46 +0200 Subject: [PATCH 11/19] main/main --- sh/log/log.sh | 4 ++-- sh/main.sh | 16 ++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/sh/log/log.sh b/sh/log/log.sh index a3013e8..f5e13b1 100644 --- a/sh/log/log.sh +++ b/sh/log/log.sh @@ -76,9 +76,9 @@ _rwx_log() { local line for line in "${@}"; do if [ -n "${prefix}" ]; then - __rwx_log "${prefix} ${line}" + _rwx_main_log "${prefix} ${line}" else - __rwx_log "${line}" + _rwx_main_log "${line}" fi done } diff --git a/sh/main.sh b/sh/main.sh index be954c5..afae042 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -69,7 +69,7 @@ rwx_shell_interactive() { # │ main │ log │ # ╰──────┴─────╯ -__rwx_log() { +_rwx_main_log() { if rwx_shell_interactive; then [ ${#} -gt 0 ] || set -- "" local line @@ -91,12 +91,12 @@ rwx_source() { local file="${2}" local count module modules count=0 - __rwx_log "" \ + _rwx_main_log "" \ ". ${root}" modules="$(rwx_find_shell "${root}" "${file}")" while IFS= read -r module; do count=$((count + 1)) - __rwx_log "$(printf "%02d" "${count}") ${module%.sh}" + _rwx_main_log "$(printf "%02d" "${count}") ${module%.sh}" # shellcheck disable=SC1090 . "${root}/${module}" # cache code @@ -133,21 +133,17 @@ ${text} # run initial steps #< code -rwx_main() { +rwx_main_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}" + _rwx_main_log "Not a directory: ${RWX_ROOT_SYSTEM}" return 1 fi # run code main function rwx_code_main } -# ╭──────┬─────╮ -# │ main │ run │ -# ╰──────┴─────╯ - # run main function -rwx_main "${@}" +rwx_main_main "${@}" From 3dceffeea509e07aa3bc5690ec78e4d51f43c72d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 06:09:14 +0200 Subject: [PATCH 12/19] code/init --- sh/code.sh | 7 ++++++- sh/self.sh | 15 ++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/sh/code.sh b/sh/code.sh index 8e59a9e..0b1403d 100644 --- a/sh/code.sh +++ b/sh/code.sh @@ -215,6 +215,11 @@ rwx_code_main() { fi # context / shell else - rwx_self_init + # run interactive extras + if rwx_shell_interactive; then + # help + rwx_log + rwx_self_help + fi fi } diff --git a/sh/self.sh b/sh/self.sh index 968c44b..314064a 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -14,23 +14,11 @@ rwx_self_help() { " u__… = user" } -# ╭──────┬──────╮ -# │ self │ init │ -# ╰──────┴──────╯ - -rwx_self_init() { - # run interactive extras - if rwx_shell_interactive; then - # help - rwx_log - rwx_self_help - fi -} - # ╭──────┬────────╮ # │ self │ subset │ # ╰──────┴────────╯ +# TODO move to code module rwx_self_subset() { local argument file root for argument in "${@}"; do @@ -51,6 +39,7 @@ rwx_self_subset() { # │ self │ write │ # ╰──────┴───────╯ +# TODO move to code module rwx_self_write() { local target="${1}" if [ -n "${target}" ]; then From c8e4fc9b41a862531bff5cf334ac69da099aa6f1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 06:17:21 +0200 Subject: [PATCH 13/19] code/help --- sh/code.sh | 14 +++++++++++++- sh/self.sh | 12 ------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sh/code.sh b/sh/code.sh index 0b1403d..a037897 100644 --- a/sh/code.sh +++ b/sh/code.sh @@ -27,6 +27,18 @@ _rwx_code_functions="" # cache for code variables _rwx_code_variables="" +# ╭──────┬──────╮ +# │ code │ help │ +# ╰──────┴──────╯ + +# output help message +rwx_code_help() { + rwx_log \ + "rwx_… = functions" \ + " a__… = aliases" \ + " u__… = user" +} + # ╭──────┬─────────╮ # │ code │ install │ # ╰──────┴─────────╯ @@ -219,7 +231,7 @@ rwx_code_main() { if rwx_shell_interactive; then # help rwx_log - rwx_self_help + rwx_code_help fi fi } diff --git a/sh/self.sh b/sh/self.sh index 314064a..76424f3 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -2,18 +2,6 @@ # │ self │ # ╰──────╯ -# ╭──────┬──────╮ -# │ self │ help │ -# ╰──────┴──────╯ - -# output help message -rwx_self_help() { - rwx_log \ - "rwx_… = functions" \ - " a__… = aliases" \ - " u__… = user" -} - # ╭──────┬────────╮ # │ self │ subset │ # ╰──────┴────────╯ From dc204d0c08798dbc3503108c34165f84624a0917 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 06:29:16 +0200 Subject: [PATCH 14/19] =?UTF-8?q?=E2=88=92indent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh/shell/bash.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/shell/bash.sh b/sh/shell/bash.sh index 20529c0..96d7376 100644 --- a/sh/shell/bash.sh +++ b/sh/shell/bash.sh @@ -4,9 +4,9 @@ # based on currently running shell case "${RWX_SHELL}" in - "bash") ;; - # skip illegal syntax to come - *) return ;; +"bash") ;; +# skip illegal syntax to come +*) return ;; esac # shellcheck disable=SC3033 From cdf0f47ca380f28db0ad2f4e5a9e338b86c5ef86 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 06:39:28 +0200 Subject: [PATCH 15/19] bash/case --- sh/shell/bash.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/shell/bash.sh b/sh/shell/bash.sh index 96d7376..2f5d2d8 100644 --- a/sh/shell/bash.sh +++ b/sh/shell/bash.sh @@ -4,8 +4,9 @@ # based on currently running shell case "${RWX_SHELL}" in +# continue if it can handle it "bash") ;; -# skip illegal syntax to come +# otherwise skip incorrect names to come *) return ;; esac From be2d6b2913fcecca4a6dfd80f270af80ef7c5944 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 06:52:28 +0200 Subject: [PATCH 16/19] fix/comments --- sh/code.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/code.sh b/sh/code.sh index a037897..4cfeb00 100644 --- a/sh/code.sh +++ b/sh/code.sh @@ -209,7 +209,7 @@ rwx_code_main() { rwx_source "${RWX_SELF_USER}" # load code cache rwx_code_load - # context / command + # set command local command # command name used to run # (stripped from hyphen interactive flag) @@ -218,6 +218,7 @@ rwx_code_main() { "bash" | "dash" | "sh") unset command ;; *) ;; esac + # context / command if [ -n "${command}" ]; then local function # find the matching function From 88478772908909d3c803e5156811adbd6aa1479a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 06:59:55 +0200 Subject: [PATCH 17/19] main/source --- sh/code.sh | 2 +- sh/main.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sh/code.sh b/sh/code.sh index 4cfeb00..76881b1 100644 --- a/sh/code.sh +++ b/sh/code.sh @@ -206,7 +206,7 @@ rwx_code_parse() { rwx_code_main() { # source user root - rwx_source "${RWX_SELF_USER}" + rwx_main_source "${RWX_SELF_USER}" # load code cache rwx_code_load # set command diff --git a/sh/main.sh b/sh/main.sh index afae042..52033e9 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -83,8 +83,8 @@ _rwx_main_log() { # │ main │ source │ # ╰──────┴────────╯ -# source code from file path -rwx_source() { +# source code from root path but file +rwx_main_source() { local root="${1}" [ -d "${root}" ] || return 1 @@ -137,7 +137,7 @@ rwx_main_main() { # cache main rwx_cache "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}" # source system root - if ! rwx_source "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}"; then + if ! rwx_main_source "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}"; then _rwx_main_log "Not a directory: ${RWX_ROOT_SYSTEM}" return 1 fi From 576d0c981cd3d798afcbc387e622ae4106ad0aae Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 07:03:26 +0200 Subject: [PATCH 18/19] main/cache --- sh/main.sh | 6 +++--- sh/test.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 52033e9..6c4ebda 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -100,7 +100,7 @@ rwx_main_source() { # shellcheck disable=SC1090 . "${root}/${module}" # cache code - rwx_cache "${root}" "${module}" + rwx_main_cache "${root}" "${module}" done < Date: Tue, 8 Jul 2025 07:07:11 +0200 Subject: [PATCH 19/19] fix --- sh/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/main.sh b/sh/main.sh index 6c4ebda..f89ee47 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -142,7 +142,7 @@ rwx_main_main() { return 1 fi # run code main function - rwx_code_main + rwx_code_main "${@}" } # run main function