Portable tst suites (awk trim instead of GNU tac) for macOS compatibility

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-19 17:44:03 +02:00
parent 2024f8059d
commit 34165108ac
2 changed files with 2 additions and 2 deletions

View File

@@ -31,7 +31,7 @@ bold=$'\033[1m'
reset=$'\033[0m' reset=$'\033[0m'
# strip leading/trailing blank lines and surrounding whitespace # 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... # check_eq TEST_NAME EXPECTED KTEXT_ARGS...
# Runs ktext, expects exit status 0, and compares trimmed stdout to EXPECTED. # Runs ktext, expects exit status 0, and compares trimmed stdout to EXPECTED.

View File

@@ -38,7 +38,7 @@ bold=$'\033[1m'
reset=$'\033[0m' reset=$'\033[0m'
# strip leading/trailing blank lines and trailing whitespace # 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 NAME EXPECTED KTEXT_ARGS... — exit 0, stdout==EXPECTED, and NO warning.
check_eq() { check_eq() {