From 23c0c1879788bb07b7ef789a1e971043c9b8c5ba Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 17:01:10 +0200 Subject: [PATCH 1/3] =?UTF-8?q?awk/=E2=86=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh/code.awk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sh/code.awk b/sh/code.awk index dd4423b..b3006ee 100644 --- a/sh/code.awk +++ b/sh/code.awk @@ -20,13 +20,14 @@ function reset() { BEGIN { RE_ANY = "(.*)" + RE_BEGIN = "^" RE_CONST = "([_A-Z][_0-9A-Z]*)" RE_SET = "=.*" RE_SPACE = "[[:space:]]" - RE_SPACES = RE_SPACE "*" RE_VAR = "([_a-z][_0-9a-z]*)" - RE_BEGIN = "^" + RE_SPACES = RE_SPACE "*" + RE_END = RE_SPACES "$" RE_FUNC = RE_SPACES "\\(" RE_SPACES "\\)" RE_SPACES "{" From faeda4feb91627d8b4d3f0d5b50294a7a795daec Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 20:37:33 +0200 Subject: [PATCH 2/3] awk/eval --- sh/code.awk | 6 +++++- sh/code.sh | 19 +------------------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/sh/code.awk b/sh/code.awk index b3006ee..dacbdc2 100644 --- a/sh/code.awk +++ b/sh/code.awk @@ -5,6 +5,10 @@ function append(line) { doc = doc line } +function eval(alias, target) { + print alias "() { " target " \"\\${@}\"; }" +} + function output(name, type) { print "↙ " type print name @@ -80,7 +84,7 @@ BEGIN { } else if (match($0, RE_FUNCTION, m)) { split(doc, array, "\n") for (item in array) { - print array[item] " " m[1] + eval(array[item], m[1]) } reset() } else { diff --git a/sh/code.sh b/sh/code.sh index d046dbb..3c033ea 100644 --- a/sh/code.sh +++ b/sh/code.sh @@ -103,21 +103,6 @@ rwx_code_aliases() { echo "${_rwx_code_aliases}" } -# find alias function -rwx_code_alias_function() { - local target="${1}" - local line name - while IFS= read -r line; do - name="$(echo "${line}" | awk "{print \$1}")" - if [ "${name}" = "${target}" ]; then - echo "${line}" | - awk "{print \$2}" - fi - done < Date: Tue, 8 Jul 2025 20:43:24 +0200 Subject: [PATCH 3/3] fix --- sh/code.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/code.awk b/sh/code.awk index dacbdc2..26f3cfc 100644 --- a/sh/code.awk +++ b/sh/code.awk @@ -6,7 +6,7 @@ function append(line) { } function eval(alias, target) { - print alias "() { " target " \"\\${@}\"; }" + print alias "() { " target " \"${@}\"; }" } function output(name, type) {