From 278dd755569eb476797f7c5225120e6689e71d89 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 8 Jul 2025 21:18:50 +0200 Subject: [PATCH] command function --- sh/code.awk | 15 +++++++++++++++ sh/code.sh | 18 +++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/sh/code.awk b/sh/code.awk index 7de8daf..c757118 100644 --- a/sh/code.awk +++ b/sh/code.awk @@ -102,6 +102,21 @@ BEGIN { } else { reset() } + } else if (action == "command function") { + if (match($0, RE_COMMAND, m)) { + append(m[1]) + } else if (match($0, RE_FUNCTION, m)) { + split(doc, array, "\n") + for (item in array) { + if (item == target) { + print m[1] + exit + } + } + reset() + } else { + reset() + } } else if (action == "doc") { # doc if (match($0, RE_SHEBANG, m)) { diff --git a/sh/code.sh b/sh/code.sh index 29e4eec..5a67869 100644 --- a/sh/code.sh +++ b/sh/code.sh @@ -105,17 +105,13 @@ rwx_code_aliases() { # find command function rwx_code_command_function() { - local target="${1}" - local line name - while IFS= read -r line; do - name="$(echo "${line}" | awk "{print \$1}")" - if [ "${name}" = "${target}" ]; then - echo "${line}" | - awk "{print \$2}" - fi - done <