From 65d701556a599ff6002f2a0388baf9c947b53db3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 11 Jul 2025 03:17:22 +0200 Subject: [PATCH] filter/functions --- sh/core/code.awk | 14 +++++--------- sh/core/code.sh | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/sh/core/code.awk b/sh/core/code.awk index 0cce4aa..3cc1b76 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -43,7 +43,7 @@ BEGIN { RE_COMMENT = RE_BEGIN "#" RE_ANY RE_END RE_CONSTANT = RE_BEGIN RE_CONST RE_SET RE_END RE_DOC = RE_BEGIN RE_SPACES "#" RE_SPACE RE_ANY RE_END - RE_FUNCTION = RE_BEGIN RE_VAR RE_FUNC RE_END + re["function"] = RE_BEGIN RE_VAR RE_FUNC RE_END RE_MODULE = RE_BEGIN "#\\." RE_SPACES RE_ANY RE_END RE_SHEBANG = RE_BEGIN "#!" RE_SPACES RE_ANY RE_END RE_TASK = RE_BEGIN RE_SPACES "#" RE_SPACES RE_TSK RE_ANY RE_END @@ -74,10 +74,6 @@ BEGIN { if (match($0, RE_CONSTANT, m)) { print m[1] } - } else if (action == "functions") { - if (match($0, RE_FUNCTION, m)) { - print m[1] - } } else if (action == "tasks") { if (match($0, RE_MODULE, m)) { if (output_tasks) { @@ -108,7 +104,7 @@ BEGIN { } else if (action == "aliases functions") { if (match($0, re["alias"], m)) { append(m[1]) - } else if (match($0, RE_FUNCTION, m)) { + } else if (match($0, re["function"], m)) { split(doc, array, "\n") for (item in array) { eval(array[item], m[1]) @@ -120,7 +116,7 @@ BEGIN { } else if (action == "commands functions") { if (match($0, RE_COMMAND, m)) { append(m[1]) - } else if (match($0, RE_FUNCTION, m)) { + } else if (match($0, re["function"], m)) { split(doc, array, "\n") for (item in array) { eval(array[item], m[1]) @@ -132,7 +128,7 @@ BEGIN { } else if (action == "command function") { if (match($0, RE_COMMAND, m)) { append(m[1]) - } else if (match($0, RE_FUNCTION, m)) { + } else if (match($0, re["function"], m)) { split(doc, array, "\n") for (item in array) { if (array[item] == target) { @@ -183,7 +179,7 @@ BEGIN { if (m[1] == target) { match_module = 1 } - } else if (match($0, RE_FUNCTION, m)) { + } else if (match($0, re["function"], m)) { f = m[1] } else if (match($0, RE_CLOSE, m)) { if (match_alias) { diff --git a/sh/core/code.sh b/sh/core/code.sh index 90f818c..b21720c 100644 --- a/sh/core/code.sh +++ b/sh/core/code.sh @@ -252,7 +252,7 @@ EOF # parse constants _rwx_code_constants="$(rwx_code_parse "constants")" # parse functions - _rwx_code_functions="$(rwx_code_parse "functions")" + _rwx_code_functions="$(rwx_code_action_target "filter" "function")" # parse tasks _rwx_code_tasks="$(rwx_code_parse "tasks")" # parse variables