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() {