From e230bbc1bfbd5929d5855e28273a5a25ca40216a Mon Sep 17 00:00:00 2001 From: Corwin Brust Date: Wed, 3 Jun 2026 08:53:45 +0000 Subject: [PATCH] (e)declare; (i)declare, add at{r,c,} --- ghostwheel.fn.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/ghostwheel.fn.sh b/ghostwheel.fn.sh index 6181f07..b60a8f4 100644 --- a/ghostwheel.fn.sh +++ b/ghostwheel.fn.sh @@ -448,6 +448,52 @@ c4.t.b "s" 0 "gw_is_localhost_f" "== hostname -f" test "0" == '"$(c4.gw_is_local c4.t.b "s" 0 "gw_is_localhost" "== hostname -s" test "0" == '"$(c4.gw_is_localhost `hostname -s`; echo "$?")"' c4.t.b "s" 0 "name" "!= moo" test "1" == '"$(c4.gw_is_localhost "moo"; echo "$?")"' +### ENVIRONMENT +### - implicit scoping, lexical binding +C4_TR='E' + +### MAP +### - two dimensional matricies +C4_TR='M' + +function c4.m.atr { + local offset=$1; shift; + local file=$1; shift; + if test -r "$file" -a "$offset" -ge 0 2>/dev/null ; then + awk "NR==$offset" <"$file" + fi +} + +C4_AWK_OPTS= +function c4.m.atc { + local C4_AWK_OPTS="${C4_AWK_OPTS}" + case "$1" in + -*) C4_AWK_OPTS="$1"; shift; ;; + esac + + local offset=$1; shift; + local file=$1; shift; + + if test -r "$file" -a "$offset" -ge 0 2>/dev/null ; then + awk $C4_AWK_OPTS "{print \$$offset}" <"$file" + fi +} + +function c4.m.at { + local C4_AWK_OPTS="${C4_AWK_OPTS}" + case "$1" in + -*) C4_AWK_OPTS="$1"; shift; ;; + esac + + local row=$1; shift; + local col=$1; shift; + local file=$1; shift; + + if test -r "$file" -a "$row" -ge 0 -a "$col" -ge 0 2>/dev/null ; then + awk $C4_AWK_OPTS "NR==$row{print \$$col}" <"$file" + fi +} + ### IDENTITY ### - bootstrapping