From ec8b41401889e4f4568d3d4befe4bc9c0ffbd40c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 7 Jul 2025 02:10:05 +0200 Subject: [PATCH] code/aliases --- readme.md | 1 - sh/code.awk | 6 +++++- sh/main.sh | 10 +++++++++- sh/test.sh | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 95fc211..9a09ee7 100644 --- a/readme.md +++ b/readme.md @@ -117,7 +117,6 @@ Two interpreted languages for flexibility. * get unresolved path for new panes & windows * fully working doc function algorithm * self install aliases -* list aliases * transfer all parsings to awk ### 6.2 [Further tasks](#when) {#when-further} diff --git a/sh/code.awk b/sh/code.awk index 33684e5..053f1be 100644 --- a/sh/code.awk +++ b/sh/code.awk @@ -46,7 +46,11 @@ BEGIN { } { - if (action == "aliases functions") { + if (action == "aliases") { + if (match($0, RE_ALIAS, m)) { + print m[1] + } + } else if (action == "aliases functions") { if (match($0, RE_ALIAS, m)) { append(m[1]) } else if (match($0, RE_FUNCTION, m)) { diff --git a/sh/main.sh b/sh/main.sh index 4ccb70b..8fe2884 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -202,7 +202,9 @@ ${RWX_REGEX_BEGIN}\\(${RWX_REGEX_VARIABLE}\\)${RWX_REGEX_SET}" _rwx_code_variables="" rwx_parse_code() { - # parse aliases commands + # parse aliases + _rwx_code_aliases="$(rwx_parse_aliases)" + # parse aliases functions local line text _rwx_code_aliases_functions="$(rwx_parse_aliases_functions)" while IFS= read -r line; do @@ -219,6 +221,12 @@ EOF # parse variables _rwx_code_variables="$(rwx_parse_variables)" } +rwx_parse_aliases() { + echo "${_rwx_code}" | + awk \ + --assign action="aliases" \ + "$(rwx_code_awk)" +} rwx_parse_aliases_functions() { printf "%s" "${_rwx_code}" | awk \ diff --git a/sh/test.sh b/sh/test.sh index dee1a65..69fcc4c 100644 --- a/sh/test.sh +++ b/sh/test.sh @@ -19,8 +19,8 @@ rwx_test_code() { "constants" \ "variables" \ "functions" \ - "aliases_functions" \ "aliases" \ + "aliases_functions" \ rwx_code for items in "${@}"; do