From 8beb437ce08cedc65cbc7bafea1dd9b49d12ea90 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 13 Jul 2025 22:15:42 +0200 Subject: [PATCH] mawk/shebang --- sh/core/code.awk | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sh/core/code.awk b/sh/core/code.awk index b7da4ef..76a8e24 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -28,6 +28,9 @@ function extract(string, type) { } else if (type == "module") { split(string, array, "#\\.") return trim(array[2]) + } else if (type == "shebang") { + split(string, array, "#!") + return trim(array[2]) } else if ((type == "constant") || (type == "variable")) { split(string, array, "=") return trim(array[1]) @@ -152,8 +155,8 @@ BEGIN { } } else if (action == "doc") { # doc - if (match($0, RE_SHEBANG, m)) { - append("! " m[1]) + if (match($0, RE_SHEBANG)) { + append("! " extract($0, "shebang")) } else if (match($0, RE_DOC, m)) { if (f) { append($0)