Compare commits
2 commits
222b64f109
...
76cd248697
Author | SHA1 | Date | |
---|---|---|---|
76cd248697 | |||
531fcacbe7 |
1 changed files with 23 additions and 23 deletions
46
sh/main.sh
46
sh/main.sh
|
@ -49,7 +49,7 @@ rwx_main() {
|
||||||
# source user root
|
# source user root
|
||||||
rwx_source "${RWX_SELF_USER}"
|
rwx_source "${RWX_SELF_USER}"
|
||||||
# parse code cache
|
# parse code cache
|
||||||
rwx_parse
|
rwx_parse_code
|
||||||
# context / command
|
# context / command
|
||||||
if [ -n "${RWX_COMMAND_NAME}" ]; then
|
if [ -n "${RWX_COMMAND_NAME}" ]; then
|
||||||
"${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}"
|
"${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}"
|
||||||
|
@ -163,30 +163,30 @@ rwx_find_shell() {
|
||||||
# │ main │ parse │
|
# │ main │ parse │
|
||||||
# ╰──────┴───────╯
|
# ╰──────┴───────╯
|
||||||
|
|
||||||
rwx_parse() {
|
RWX_REGEX_CONSTANT="[_A-Z][_0-9A-Z]*"
|
||||||
local ws="[[:space:]]*"
|
RWX_REGEX_FUNCTION="[_A-Za-z][_0-9A-Za-z]*"
|
||||||
local start="^${ws}"
|
RWX_REGEX_SET="=.*"
|
||||||
local constant="[_A-Z][_0-9A-Z]*"
|
RWX_REGEX_SPACES="[[:space:]]*"
|
||||||
local setting="=.*"
|
|
||||||
local func="${ws}(${ws})${ws}{.*"
|
RWX_REGEX_BEGIN="^${RWX_REGEX_SPACES}"
|
||||||
local id="[_a-zA-Z][_a-z0-9A-Z]*"
|
RWX_REGEX_OPEN="\
|
||||||
local line
|
${RWX_REGEX_SPACES}(${RWX_REGEX_SPACES})${RWX_REGEX_SPACES}{.*"
|
||||||
RWX_CONSTANTS=""
|
|
||||||
|
rwx_parse_code() {
|
||||||
|
# parse constants
|
||||||
|
RWX_CONSTANTS="$(rwx_parse_constants)"
|
||||||
|
# parse functions
|
||||||
|
RWX_FUNCTIONS="$(rwx_parse_functions)"
|
||||||
|
}
|
||||||
|
rwx_parse_constants() {
|
||||||
printf "%s\n" "${RWX_CODE}" |
|
printf "%s\n" "${RWX_CODE}" |
|
||||||
grep "${start}${constant}${setting}" |
|
grep "${RWX_REGEX_BEGIN}${RWX_REGEX_CONSTANT}${RWX_REGEX_SET}" |
|
||||||
sed "s|${start}\\(${constant}\\)${setting}|\\1|" |
|
sed "s|${RWX_REGEX_BEGIN}\\(${RWX_REGEX_CONSTANT}\\)${RWX_REGEX_SET}|\\1|"
|
||||||
while IFS= read -r line; do
|
}
|
||||||
RWX_CONSTANTS="${RWX_CONSTANTS}${line}
|
rwx_parse_functions() {
|
||||||
"
|
|
||||||
done
|
|
||||||
RWX_FUNCTIONS=""
|
|
||||||
printf "%s\n" "${RWX_CODE}" |
|
printf "%s\n" "${RWX_CODE}" |
|
||||||
grep "${start}${id}${func}" |
|
grep "${RWX_REGEX_BEGIN}${RWX_REGEX_FUNCTION}${RWX_REGEX_OPEN}" |
|
||||||
sed "s|${start}\\(${id}\\)${func}|\\1|" |
|
sed "s|${RWX_REGEX_BEGIN}\\(${RWX_REGEX_FUNCTION}\\)${RWX_REGEX_OPEN}|\\1|"
|
||||||
while IFS= read -r line; do
|
|
||||||
RWX_FUNCTIONS="${RWX_FUNCTIONS}${line}
|
|
||||||
"
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ╭──────┬─────╮
|
# ╭──────┬─────╮
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue