parse/code,constants,functions
All checks were successful
/ job (push) Successful in 4m56s

This commit is contained in:
Marc Beninca 2025-07-04 07:44:31 +02:00
parent 531fcacbe7
commit 76cd248697
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -49,7 +49,7 @@ rwx_main() {
# source user root
rwx_source "${RWX_SELF_USER}"
# parse code cache
rwx_parse
rwx_parse_code
# context / command
if [ -n "${RWX_COMMAND_NAME}" ]; then
"${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}"
@ -172,26 +172,21 @@ RWX_REGEX_BEGIN="^${RWX_REGEX_SPACES}"
RWX_REGEX_OPEN="\
${RWX_REGEX_SPACES}(${RWX_REGEX_SPACES})${RWX_REGEX_SPACES}{.*"
rwx_parse() {
local line
rwx_parse_code() {
# parse constants
RWX_CONSTANTS=""
RWX_CONSTANTS="$(rwx_parse_constants)"
# parse functions
RWX_FUNCTIONS="$(rwx_parse_functions)"
}
rwx_parse_constants() {
printf "%s\n" "${RWX_CODE}" |
grep "${RWX_REGEX_BEGIN}${RWX_REGEX_CONSTANT}${RWX_REGEX_SET}" |
sed "s|${RWX_REGEX_BEGIN}\\(${RWX_REGEX_CONSTANT}\\)${RWX_REGEX_SET}|\\1|" |
while IFS= read -r line; do
RWX_CONSTANTS="${RWX_CONSTANTS}${line}
"
done
# parse functions
RWX_FUNCTIONS=""
sed "s|${RWX_REGEX_BEGIN}\\(${RWX_REGEX_CONSTANT}\\)${RWX_REGEX_SET}|\\1|"
}
rwx_parse_functions() {
printf "%s\n" "${RWX_CODE}" |
grep "${RWX_REGEX_BEGIN}${RWX_REGEX_FUNCTION}${RWX_REGEX_OPEN}" |
sed "s|${RWX_REGEX_BEGIN}\\(${RWX_REGEX_FUNCTION}\\)${RWX_REGEX_OPEN}|\\1|" |
while IFS= read -r line; do
RWX_FUNCTIONS="${RWX_FUNCTIONS}${line}
"
done
sed "s|${RWX_REGEX_BEGIN}\\(${RWX_REGEX_FUNCTION}\\)${RWX_REGEX_OPEN}|\\1|"
}
# ╭──────┬─────╮