From 71a1ba65167af570d5f210011d5fa71ae1a9bcaa Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 22:13:38 +0200 Subject: [PATCH 1/9] core/code --- sh/code.sh | 2 +- sh/main.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/code.sh b/sh/code.sh index e4ff098..139c578 100644 --- a/sh/code.sh +++ b/sh/code.sh @@ -13,7 +13,7 @@ RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" # cache for the parsing awk script -_rwx_code_awk="$(cat "${RWX_ROOT_SYSTEM}/code.awk")" +_rwx_code_awk="$(cat "${RWX_ROOT_SYSTEM}/core/code.awk")" # cache for code aliases _rwx_code_aliases="" # cache for code aliases functions diff --git a/sh/main.sh b/sh/main.sh index f89ee47..a7240fc 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -132,7 +132,7 @@ ${text} # ╰──────┴──────╯ # run initial steps -#< code +#< core/code rwx_main_main() { # cache main rwx_main_cache "${RWX_ROOT_SYSTEM}" "${RWX_MAIN_NAME}" From bf0e3943d8f30f4a4073357531ce6027ba95d13b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 22:14:07 +0200 Subject: [PATCH 2/9] core/code --- sh/{ => core}/code.awk | 0 sh/{ => core}/code.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename sh/{ => core}/code.awk (100%) rename sh/{ => core}/code.sh (100%) diff --git a/sh/code.awk b/sh/core/code.awk similarity index 100% rename from sh/code.awk rename to sh/core/code.awk diff --git a/sh/code.sh b/sh/core/code.sh similarity index 100% rename from sh/code.sh rename to sh/core/code.sh From e9b57b693ceaee100b67fd217ad769d6df35330b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 23:43:35 +0200 Subject: [PATCH 3/9] =?UTF-8?q?=E2=88=92useless?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh/core/code.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/core/code.sh b/sh/core/code.sh index 139c578..0dec949 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -181,7 +181,7 @@ rwx_code_doc() { } rwx_code_load() { - local line text + local line # parse aliases functions _rwx_code_aliases_functions="$(rwx_code_parse "aliases functions")" while IFS= read -r line; do From c11edc243f811f1a55635592d1ab59e39e67b58c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 9 Jul 2025 00:18:57 +0200 Subject: [PATCH 4/9] main/interactive --- sh/core/code.sh | 2 +- sh/main.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sh/core/code.sh b/sh/core/code.sh index 0dec949..2908f7c 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -247,7 +247,7 @@ rwx_code_main() { # context / shell else # run interactive extras - if rwx_shell_interactive; then + if rwx_main_interactive; then # help rwx_log rwx_code_help diff --git a/sh/main.sh b/sh/main.sh index a7240fc..a8d1321 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -58,7 +58,7 @@ rwx_find_shell() { # ╰──────┴───────╯ # test if active shell is in interactive mode -rwx_shell_interactive() { +rwx_main_interactive() { case "${-}" in *i*) ;; *) return 1 ;; @@ -70,7 +70,7 @@ rwx_shell_interactive() { # ╰──────┴─────╯ _rwx_main_log() { - if rwx_shell_interactive; then + if rwx_main_interactive; then [ ${#} -gt 0 ] || set -- "" local line for line in "${@}"; do From 048f41cd057c2afd4a886b34f3a3e84e52483e1b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 9 Jul 2025 00:39:58 +0200 Subject: [PATCH 5/9] code/help --- sh/core/code.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sh/core/code.sh b/sh/core/code.sh index 2908f7c..393e5d5 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -37,7 +37,7 @@ _rwx_code_variables="" # output help message rwx_code_help() { - rwx_log \ + rwx_log "" \ "rwx_… = functions" \ " a__… = aliases" \ " u__… = user" @@ -246,11 +246,7 @@ rwx_code_main() { fi # context / shell else - # run interactive extras - if rwx_main_interactive; then - # help - rwx_log - rwx_code_help - fi + # display help + rwx_code_help fi } From 222972b6df7a7d17485cd4635578a34bc6b0c6ba Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 9 Jul 2025 01:04:59 +0200 Subject: [PATCH 6/9] main/find --- sh/lint/shellcheck.sh | 2 +- sh/main.sh | 18 ++++++------------ sh/self.sh | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/sh/lint/shellcheck.sh b/sh/lint/shellcheck.sh index 0253062..c6aabb6 100644 --- a/sh/lint/shellcheck.sh +++ b/sh/lint/shellcheck.sh @@ -2,7 +2,7 @@ rwx_shellcheck() { local root="${1}" local file module modules path file="$(mktemp)" - modules="$(rwx_find_shell "${root}")" + modules="$(rwx_main_find "${root}")" while IFS= read -r module; do path="${root}/${module}" echo ". \"${path}\"" >>"${file}" diff --git a/sh/main.sh b/sh/main.sh index a8d1321..4910ba8 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -28,16 +28,15 @@ RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" # │ main │ find │ # ╰──────┴──────╯ -# find directory’s files by extension +# find directory’s shell files #| find #| sort -rwx_find_extension() { - local extension="${1}" - local root="${2}" - local file="${3}" +rwx_main_find() { + local root="${1}" + local file="${2}" set -- \ "${root}" \ - -name "*.${extension}" \ + -name "*.sh" \ -type "f" [ -n "${file}" ] && set -- "${@}" \ @@ -48,11 +47,6 @@ rwx_find_extension() { sort } -# find directory’s sh files -rwx_find_shell() { - rwx_find_extension "sh" "${@}" -} - # ╭──────┬───────╮ # │ main │ shell │ # ╰──────┴───────╯ @@ -93,7 +87,7 @@ rwx_main_source() { count=0 _rwx_main_log "" \ ". ${root}" - modules="$(rwx_find_shell "${root}" "${file}")" + modules="$(rwx_main_find "${root}" "${file}")" while IFS= read -r module; do count=$((count + 1)) _rwx_main_log "$(printf "%02d" "${count}") ${module%.sh}" diff --git a/sh/self.sh b/sh/self.sh index 76424f3..a8a6dbf 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -14,7 +14,7 @@ rwx_self_subset() { file="${argument}.sh" if [ -d "${root}" ]; then local file - for file in $(rwx_find_shell "${root}"); do + for file in $(rwx_main_find "${root}"); do echo "${argument}/${file}" done elif [ -f "${RWX_ROOT_SYSTEM}/${file}" ]; then From e060c189498cb86282fdf1b705531baf998bb86a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 9 Jul 2025 02:04:14 +0200 Subject: [PATCH 7/9] simplify --- sh/core/code.sh | 2 +- sh/lint/shellcheck.sh | 2 +- sh/main.sh | 42 ++++++++++++++++++++---------------------- sh/self.sh | 2 +- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/sh/core/code.sh b/sh/core/code.sh index 393e5d5..18860ab 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -8,7 +8,7 @@ # TODO variablize # path to the entrypoint main file of the project -RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" +RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}.sh" # user root directory of the project RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" diff --git a/sh/lint/shellcheck.sh b/sh/lint/shellcheck.sh index c6aabb6..3bdfa07 100644 --- a/sh/lint/shellcheck.sh +++ b/sh/lint/shellcheck.sh @@ -4,7 +4,7 @@ rwx_shellcheck() { file="$(mktemp)" modules="$(rwx_main_find "${root}")" while IFS= read -r module; do - path="${root}/${module}" + path="${root}/${module}.sh" echo ". \"${path}\"" >>"${file}" done < Date: Wed, 9 Jul 2025 02:10:12 +0200 Subject: [PATCH 8/9] lint --- sh/main.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index 297cdbb..ed09edf 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -34,14 +34,13 @@ RWX_ROOT_SYSTEM="/usr/local/lib/${RWX_SELF_NAME}" #| sort rwx_main_find() { local root="${1}" - local file="${2}" find \ "${root}" \ -name "*.sh" \ -type "f" \ -printf "%P\n" | - sed "s|\\.[^.]*\$||" | - sort + sed "s|\\.[^.]*\$||" | + sort } # ╭──────┬───────╮ @@ -108,13 +107,12 @@ EOF rwx_main_cache() { local root="${1}" local module="${2}" - local name="${module}" local path="${root}/${module}.sh" local text text="$(cat "${path}")" # all source code _rwx_code="${_rwx_code}\ -#. ${name} +#. ${module} ${text} " } From 99de96a3934912b980a479e2feab2f062a8e52fb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 9 Jul 2025 02:20:50 +0200 Subject: [PATCH 9/9] main/extension --- sh/core/code.sh | 6 +++--- sh/lint/shellcheck.sh | 2 +- sh/main.sh | 9 ++++++--- sh/self.sh | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/sh/core/code.sh b/sh/core/code.sh index 18860ab..a4a5eb0 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -8,7 +8,7 @@ # TODO variablize # path to the entrypoint main file of the project -RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}.sh" +RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}.${RWX_MAIN_EXTENSION}" # user root directory of the project RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}" @@ -59,7 +59,7 @@ rwx_code_install() { fi # commands root="${target}/usr/local/bin" - name="${RWX_SELF_NAME}.sh" + name="${RWX_SELF_NAME}.${RWX_MAIN_EXTENSION}" file="${root}/${name}" rwx_remove "${file}" rwx_link "${file}" "${RWX_MAIN_PATH}" @@ -71,7 +71,7 @@ rwx_code_install() { ${_rwx_code_commands} EOF # sh - file="${target}/etc/profile.d/${RWX_SELF_NAME}.sh" + file="${target}/etc/profile.d/${RWX_SELF_NAME}.${RWX_MAIN_EXTENSION}" rwx_remove "${file}" rwx_file_write "${file}" "\ export ENV=\"${RWX_MAIN_PATH}\" diff --git a/sh/lint/shellcheck.sh b/sh/lint/shellcheck.sh index 3bdfa07..75101f2 100644 --- a/sh/lint/shellcheck.sh +++ b/sh/lint/shellcheck.sh @@ -4,7 +4,7 @@ rwx_shellcheck() { file="$(mktemp)" modules="$(rwx_main_find "${root}")" while IFS= read -r module; do - path="${root}/${module}.sh" + path="${root}/${module}.${RWX_MAIN_EXTENSION}" echo ". \"${path}\"" >>"${file}" done <