From 34165108acb53b192fae4f7f64242767dc22caa3 Mon Sep 17 00:00:00 2001 From: Andy Kopra Date: Sun, 19 Jul 2026 17:44:03 +0200 Subject: [PATCH] Portable tst suites (awk trim instead of GNU tac) for macOS compatibility Co-Authored-By: Claude Opus 4.8 (1M context) --- tst/cond_test.sh | 2 +- tst/deftype_test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tst/cond_test.sh b/tst/cond_test.sh index 94d4bcd..4229829 100755 --- a/tst/cond_test.sh +++ b/tst/cond_test.sh @@ -31,7 +31,7 @@ bold=$'\033[1m' reset=$'\033[0m' # strip leading/trailing blank lines and surrounding whitespace -trim() { sed -e 's/[[:space:]]*$//' | sed -e '/./,$!d' | tac | sed -e '/./,$!d' | tac; } +trim() { awk '{ sub(/[ \t\r]+$/, "") } { line[NR]=$0 } END { f=1; while (f<=NR && line[f]=="") f++; l=NR; while (l>=1 && line[l]=="") l--; for (i=f;i<=l;i++) print line[i] }'; } # check_eq TEST_NAME EXPECTED KTEXT_ARGS... # Runs ktext, expects exit status 0, and compares trimmed stdout to EXPECTED. diff --git a/tst/deftype_test.sh b/tst/deftype_test.sh index 6e03ea1..a16dd22 100755 --- a/tst/deftype_test.sh +++ b/tst/deftype_test.sh @@ -38,7 +38,7 @@ bold=$'\033[1m' reset=$'\033[0m' # strip leading/trailing blank lines and trailing whitespace -trim() { sed -e 's/[[:space:]]*$//' | sed -e '/./,$!d' | tac | sed -e '/./,$!d' | tac; } +trim() { awk '{ sub(/[ \t\r]+$/, "") } { line[NR]=$0 } END { f=1; while (f<=NR && line[f]=="") f++; l=NR; while (l>=1 && line[l]=="") l--; for (i=f;i<=l;i++) print line[i] }'; } # check_eq NAME EXPECTED KTEXT_ARGS... — exit 0, stdout==EXPECTED, and NO warning. check_eq() {