From 845065a374bf01752d19cdc3d1cbdb313fe3f4b5 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 2 Aug 2025 10:45:32 +0200 Subject: [PATCH] awk/actions,comments --- sh/core/code.awk | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/sh/core/code.awk b/sh/core/code.awk index 80c69b9..7b18345 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -64,8 +64,7 @@ function trim(string) { return text } -# begin - +# → begin BEGIN { RE_ANY = "(.*)" @@ -101,23 +100,20 @@ match_module = 0 match_task = 0 reset() +# ← begin } # parse - function parse(string) { } -# main - +# → main { -if (action == "filter") { - if (match($0, re[target])) { - unique[extract($0, target)] = "" - } +# FIXME handle no action -} else if (action == "tasks") { +# tasks +if (action == "tasks") { line++ if (match($0, RE_MODULE)) { line = 1 @@ -149,6 +145,7 @@ if (action == "filter") { match_task = 0 } +# eval } else if (action == "eval") { if (match($0, re[target])) { append(extract($0, target)) @@ -162,6 +159,7 @@ if (action == "filter") { reset() } +# function } else if (action == "function") { if (match($0, re["command"])) { append(extract($0, "command")) @@ -178,6 +176,7 @@ if (action == "filter") { reset() } +# doc } else if (action == "doc") { # doc if (match($0, RE_SHEBANG)) { @@ -243,18 +242,30 @@ if (action == "filter") { reset() } } + +# filter +} else if (action == "filter") { + if (match($0, re[target])) { + unique[extract($0, target)] = "" + } + +# ← action } +# ← main } -# end - +# → end END { +# filter if (action == "filter") { for (item in unique) { print item } + +# ← end / action } +# ← end }