From fc19ff4cbe2b24773463422afb2507ba74088ae6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 2 Aug 2025 17:15:23 +0200 Subject: [PATCH] parse/alias,command --- sh/core/code.awk | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/sh/core/code.awk b/sh/core/code.awk index 41baf26..033fb47 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -94,8 +94,6 @@ RE_SHEBANG = RE_BEGIN "#!" RE_SPACES RE_ANY RE_END RE_TASK = RE_BEGIN RE_SPACES "#" RE_SPACES RE_TSK RE_ANY RE_END re["variable"] = RE_BEGIN RE_VAR RE_SET RE_END -match_alias = 0 -match_command = 0 match_task = 0 doc_reset() @@ -121,6 +119,24 @@ function parse(string) { sub("#!", "", shebang) shebang = trim(shebang) + # alias + } else if (match(string, re["alias"])) { + current_match = "alias" + alias = string + sub("#=", "", alias) + alias = trim(alias) + aliases[alias] = "" + doc_append("= " alias) + + # command + } else if (match(string, re["command"])) { + current_match = "command" + command = string + sub("#/", "", command) + command = trim(command) + commands[command] = "" + doc_append("/ " command) + # other } else { if (module == target) { @@ -145,18 +161,6 @@ if (action == "doc") { } else { doc_append(extract($0, "doc")) } - } else if (match($0, re["alias"])) { - matched = extract($0, "alias") - doc_append("= " matched) - if (matched == target) { - match_alias = 1 - } - } else if (match($0, re["command"])) { - matched = extract($0, "command") - doc_append("/ " matched) - if (matched == target) { - match_command = 1 - } # set } else if (match($0, re["constant"])) { matched = extract($0, "constant")