mawk/shebang

This commit is contained in:
Marc Beninca 2025-07-13 22:15:42 +02:00
parent 596126bb85
commit 8beb437ce0
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -28,6 +28,9 @@ function extract(string, type) {
} else if (type == "module") { } else if (type == "module") {
split(string, array, "#\\.") split(string, array, "#\\.")
return trim(array[2]) return trim(array[2])
} else if (type == "shebang") {
split(string, array, "#!")
return trim(array[2])
} else if ((type == "constant") || (type == "variable")) { } else if ((type == "constant") || (type == "variable")) {
split(string, array, "=") split(string, array, "=")
return trim(array[1]) return trim(array[1])
@ -152,8 +155,8 @@ BEGIN {
} }
} else if (action == "doc") { } else if (action == "doc") {
# doc # doc
if (match($0, RE_SHEBANG, m)) { if (match($0, RE_SHEBANG)) {
append("! " m[1]) append("! " extract($0, "shebang"))
} else if (match($0, RE_DOC, m)) { } else if (match($0, RE_DOC, m)) {
if (f) { if (f) {
append($0) append($0)