This commit is contained in:
parent
531fcacbe7
commit
76cd248697
1 changed files with 11 additions and 16 deletions
27
sh/main.sh
27
sh/main.sh
|
@ -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|"
|
||||
}
|
||||
|
||||
# ╭──────┬─────╮
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue