awk/actions,comments

This commit is contained in:
Marc Beninca 2025-08-02 10:45:32 +02:00
parent 037c64674e
commit 845065a374
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -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
}