From b87a7cabc5b482973b7fa014ef099dd32e105214 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Thu, 14 May 2020 18:33:47 +0100 Subject: [PATCH] tests/locale.sh: fix test that depended on 'od' whitespace output Different implementations of the 'od' command may legitimately vary the whitespace they output between fields. One of the regression tests checked 'od' output without tolerating whitespace varieties, which is not portable. For example, the BSD 'od' implementation outputs more whitespace than the variant used to write the test. src/cmd/ksh93/tests/locale.sh: - In test "incorrect string from printf %q", use 'awk' to eliminate whitespace from 'od' output before checking results. (cherry picked from commit 7aa830bd3a2284f7228ee7189f5671749c3f2682) --- src/cmd/ksh93/tests/locale.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cmd/ksh93/tests/locale.sh b/src/cmd/ksh93/tests/locale.sh index 262fae7dc..c95635910 100755 --- a/src/cmd/ksh93/tests/locale.sh +++ b/src/cmd/ksh93/tests/locale.sh @@ -330,8 +330,11 @@ then LC_ALL=en_US.UTF-8 x=$(printf "hello\u[20ac]\xee world") [[ $(print -r -- "$x") == $'hello\u[20ac]\xee world' ]] || err_exit '%q with unicode and non-unicode not working' if [[ $(whence od) ]] - then got='68 65 6c 6c 6f e2 82 ac ee 20 77 6f 72 6c 64 0a' - [[ $(print -r -- "$x" | od -An -tx1) == "$got" ]] || err_exit "incorrect string from printf %q" + then got='68656c6c6fe282acee20776f726c640a' + [[ $(print -r -- "$x" | od -An -tx1 \ + | awk 'BEGIN { ORS=""; } { for (i=1; i<=NF; i++) print $i; }') \ + == "$got" ]] \ + || err_exit "incorrect string from printf %q" fi fi