From ba8dee99e7a6ea47973c954a0a00b29b74cee983 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 11 Jul 2025 16:24:24 +0200 Subject: [PATCH 1/6] code/functions --- sh/core/code.sh | 180 +++++++++++++++++++++++++----------------------- 1 file changed, 92 insertions(+), 88 deletions(-) diff --git a/sh/core/code.sh b/sh/core/code.sh index 4c12e49..7d7e166 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -41,14 +41,30 @@ _rwx_code_tasks_todo="" # cache for code variables _rwx_code_variables="" -# ╭──────┬───────╮ -# │ code │ cache │ -# ╰──────┴───────╯ +# ╭──────┬───────────╮ +# │ code │ functions │ +# ╰──────┴───────────╯ -# output all cached code -rwx_code_cache() { - rwx_code_cache_main - rwx_code_cache_user +# show the cached awk script +rwx_code_awk() { + echo "${_rwx_code_awk}" +} + +# show the cached aliases +#= rca +rwx_code_aliases() { + echo "${_rwx_code_aliases}" +} + +# show the cached aliases and functions +#= rcaf +rwx_code_aliases_functions() { + echo "${_rwx_code_aliases_functions}" +} + +# show the cached binaries +rwx_code_binaries() { + echo "${_rwx_code_binaries}" } # output cached main code @@ -61,6 +77,75 @@ rwx_code_cache_user() { echo "${rwx_code_cache_user}" } +# show the cached commands +rwx_code_commands() { + echo "${_rwx_code_commands}" +} + +# show the cached commands and functions +#= rccf +rwx_code_commands_functions() { + echo "${_rwx_code_commands_functions}" +} + +# show the cached constants +#= rcc +rwx_code_constants() { + echo "${_rwx_code_constants}" +} + +# show the cached functions +#= rcf +rwx_code_functions() { + echo "${_rwx_code_functions}" +} + +# show the cached main modules +#= rcmm +rwx_code_modules_main() { + echo "${rwx_code_modules_main}" +} + +# show the cached user modules +#= rcmu +rwx_code_modules_user() { + echo "${rwx_code_modules_user}" +} + +# show the cached tasks +#= rct +rwx_code_tasks() { + echo "${_rwx_code_tasks}" +} + +# show the cached fixme tasks +#= rctf +rwx_code_tasks_fixme() { + echo "${_rwx_code_tasks_fixme}" +} + +# show the cached todo tasks +#= rctt +rwx_code_tasks_todo() { + echo "${_rwx_code_tasks_todo}" +} + +# show the cached variables +#= rcv +rwx_code_variables() { + echo "${_rwx_code_variables}" +} + +# ╭──────┬───────╮ +# │ code │ cache │ +# ╰──────┴───────╯ + +# output all cached code +rwx_code_cache() { + rwx_code_cache_main + rwx_code_cache_user +} + # ╭──────┬─────────╮ # │ code │ install │ # ╰──────┴─────────╯ @@ -104,11 +189,6 @@ export ENV=\"${rwx_main_path}\" # │ code │ parts │ # ╰──────┴───────╯ -# show the cached awk script -rwx_code_awk() { - echo "${_rwx_code_awk}" -} - # call awk for action with target rwx_code_action_target() { local action="${1}" @@ -121,12 +201,6 @@ rwx_code_action_target() { "${_rwx_code_awk}" } -# show the cached aliases -#= rca -rwx_code_aliases() { - echo "${_rwx_code_aliases}" -} - # find command function rwx_code_command_function() { local name="${1}" @@ -138,40 +212,6 @@ rwx_code_command_function() { "${_rwx_code_awk}" } -# show the cached aliases and functions -#= rcaf -rwx_code_aliases_functions() { - echo "${_rwx_code_aliases_functions}" -} - -# show the cached binaries -rwx_code_binaries() { - echo "${_rwx_code_binaries}" -} - -# show the cached commands -rwx_code_commands() { - echo "${_rwx_code_commands}" -} - -# show the cached commands and functions -#= rccf -rwx_code_commands_functions() { - echo "${_rwx_code_commands_functions}" -} - -# show the cached constants -#= rcc -rwx_code_constants() { - echo "${_rwx_code_constants}" -} - -# show the cached functions -#= rcf -rwx_code_functions() { - echo "${_rwx_code_functions}" -} - # show all the cached main modules #= rcm rwx_code_modules() { @@ -179,42 +219,6 @@ rwx_code_modules() { rwx_code_modules_user } -# show the cached main modules -#= rcmm -rwx_code_modules_main() { - echo "${rwx_code_modules_main}" -} - -# show the cached user modules -#= rcmu -rwx_code_modules_user() { - echo "${rwx_code_modules_user}" -} - -# show the cached tasks -#= rct -rwx_code_tasks() { - echo "${_rwx_code_tasks}" -} - -# show the cached fixme tasks -#= rctf -rwx_code_tasks_fixme() { - echo "${_rwx_code_tasks_fixme}" -} - -# show the cached todo tasks -#= rctt -rwx_code_tasks_todo() { - echo "${_rwx_code_tasks_todo}" -} - -# show the cached variables -#= rcv -rwx_code_variables() { - echo "${_rwx_code_variables}" -} - # ╭──────┬───────╮ # │ code │ parse │ # ╰──────┴───────╯ From c3449a1148efee11da316f50d4a815e3b09b181e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 11 Jul 2025 23:00:49 +0200 Subject: [PATCH 2/6] filter/unique --- sh/core/code.awk | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sh/core/code.awk b/sh/core/code.awk index bfdd362..c21262f 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -64,7 +64,7 @@ BEGIN { { if (action == "filter") { if (match($0, re[target], m)) { - print m[1] + unique[m[1]] = "" } } else if (action == "binaries") { if (match($0, RE_BINARY, m)) { @@ -211,7 +211,11 @@ BEGIN { } END { - if (action == "binaries") { + if (action == "filter") { + for (item in unique) { + print item + } + } else if (action == "binaries") { for (binary in binaries) { print binary } From 38bcab046b9155e6fc3831318e32d07b1f232f05 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 11 Jul 2025 23:14:57 +0200 Subject: [PATCH 3/6] code/binaries --- sh/core/code.awk | 10 +--------- sh/core/code.sh | 4 ++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/sh/core/code.awk b/sh/core/code.awk index c21262f..3ed41ed 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -41,7 +41,7 @@ BEGIN { RE_FUNC = RE_SPACES "\\(" RE_SPACES "\\)" RE_SPACES "{" re["alias"] = RE_BEGIN "#=" RE_SPACES RE_VAR RE_END - RE_BINARY = RE_BEGIN "#\\|" RE_SPACES RE_VAR RE_END + re["binary"] = RE_BEGIN "#\\|" RE_SPACES RE_VAR RE_END RE_CLOSE = RE_BEGIN "}" RE_SPACES RE_END RE_COMMAND = RE_BEGIN "#/" RE_SPACES RE_VAR RE_END RE_COMMENT = RE_BEGIN "#" RE_ANY RE_END @@ -66,10 +66,6 @@ BEGIN { if (match($0, re[target], m)) { unique[m[1]] = "" } - } else if (action == "binaries") { - if (match($0, RE_BINARY, m)) { - binaries[m[1]] = "" - } } else if (action == "commands") { if (match($0, RE_COMMAND, m)) { print m[1] @@ -215,10 +211,6 @@ END { for (item in unique) { print item } - } else if (action == "binaries") { - for (binary in binaries) { - print binary - } } # FIXME tasks last module end } diff --git a/sh/core/code.sh b/sh/core/code.sh index 7d7e166..f4ca676 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -264,11 +264,11 @@ EOF # parse aliases _rwx_code_aliases="$(rwx_code_action_target "filter" "alias")" # parse binaries - _rwx_code_binaries="$(rwx_code_parse "binaries")" + _rwx_code_binaries="$(rwx_code_action_target "filter" "binary")" # parse commands _rwx_code_commands="$(rwx_code_parse "commands")" # parse constants - _rwx_code_constants="$(rwx_code_action_target "filter" "constants")" + _rwx_code_constants="$(rwx_code_action_target "filter" "constant")" # parse functions _rwx_code_functions="$(rwx_code_action_target "filter" "function")" # parse tasks From 28064567e119ac6c5bfdd0000ca304b8439cbac2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 11 Jul 2025 23:28:18 +0200 Subject: [PATCH 4/6] sortings --- sh/core/code.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sh/core/code.sh b/sh/core/code.sh index f4ca676..e88963c 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -262,21 +262,21 @@ EOF ${_rwx_code_commands_functions} EOF # parse aliases - _rwx_code_aliases="$(rwx_code_action_target "filter" "alias")" + _rwx_code_aliases="$(rwx_code_action_target "filter" "alias" | sort)" # parse binaries _rwx_code_binaries="$(rwx_code_action_target "filter" "binary")" # parse commands _rwx_code_commands="$(rwx_code_parse "commands")" # parse constants - _rwx_code_constants="$(rwx_code_action_target "filter" "constant")" + _rwx_code_constants="$(rwx_code_action_target "filter" "constant" | sort)" # parse functions - _rwx_code_functions="$(rwx_code_action_target "filter" "function")" + _rwx_code_functions="$(rwx_code_action_target "filter" "function" | sort)" # parse tasks _rwx_code_tasks="$(rwx_code_action_target "tasks")" _rwx_code_tasks_fixme="$(rwx_code_action_target "tasks" "FIXME")" _rwx_code_tasks_todo="$(rwx_code_action_target "tasks" "TODO")" # parse variables - _rwx_code_variables="$(rwx_code_action_target "filter" "variable")" + _rwx_code_variables="$(rwx_code_action_target "filter" "variable" | sort)" } rwx_code_parse() { From 148a9aef966bb1a5125a188d1ae26e015e284158 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 11 Jul 2025 23:34:46 +0200 Subject: [PATCH 5/6] code/commands --- sh/core/code.awk | 12 ++++-------- sh/core/code.sh | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/sh/core/code.awk b/sh/core/code.awk index 3ed41ed..89d0816 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -43,7 +43,7 @@ BEGIN { re["alias"] = RE_BEGIN "#=" RE_SPACES RE_VAR RE_END re["binary"] = RE_BEGIN "#\\|" RE_SPACES RE_VAR RE_END RE_CLOSE = RE_BEGIN "}" RE_SPACES RE_END - RE_COMMAND = RE_BEGIN "#/" RE_SPACES RE_VAR RE_END + re["command"] = RE_BEGIN "#/" RE_SPACES RE_VAR RE_END RE_COMMENT = RE_BEGIN "#" RE_ANY RE_END re["constant"] = RE_BEGIN RE_CONST RE_SET RE_END RE_DOC = RE_BEGIN RE_SPACES "#" RE_SPACE RE_ANY RE_END @@ -66,10 +66,6 @@ BEGIN { if (match($0, re[target], m)) { unique[m[1]] = "" } - } else if (action == "commands") { - if (match($0, RE_COMMAND, m)) { - print m[1] - } } else if (action == "tasks") { if (match($0, RE_MODULE, m)) { if (output_tasks) { @@ -116,7 +112,7 @@ BEGIN { reset() } } else if (action == "commands functions") { - if (match($0, RE_COMMAND, m)) { + if (match($0, re["command"], m)) { append(m[1]) } else if (match($0, re["function"], m)) { split(doc, array, "\n") @@ -128,7 +124,7 @@ BEGIN { reset() } } else if (action == "command function") { - if (match($0, RE_COMMAND, m)) { + if (match($0, re["command"], m)) { append(m[1]) } else if (match($0, re["function"], m)) { split(doc, array, "\n") @@ -157,7 +153,7 @@ BEGIN { if (m[1] == target) { match_alias = 1 } - } else if (match($0, RE_COMMAND, m)) { + } else if (match($0, re["command"], m)) { append("/ " m[1]) if (m[1] == target) { match_command = 1 diff --git a/sh/core/code.sh b/sh/core/code.sh index e88963c..6ea16c5 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -266,7 +266,7 @@ EOF # parse binaries _rwx_code_binaries="$(rwx_code_action_target "filter" "binary")" # parse commands - _rwx_code_commands="$(rwx_code_parse "commands")" + _rwx_code_commands="$(rwx_code_action_target "filter" "command")" # parse constants _rwx_code_constants="$(rwx_code_action_target "filter" "constant" | sort)" # parse functions From 56b77357bb984f5dbb0d7ec2ca77df1eddb9c129 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 11 Jul 2025 23:41:11 +0200 Subject: [PATCH 6/6] fix --- sh/main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sh/main.sh b/sh/main.sh index d3f9ccf..a897809 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -71,9 +71,9 @@ rwx_main_main() { ${modules} EOF # run code module main function with found main modules - rwx_code_main "${modules}" "${@}" + rwx_code_main "${modules}" # run shell module main function - rwx_shell_main + rwx_shell_main "${@}" } # run main function