From 72a013fd7e114a120055a101633e948453302b75 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Sat, 24 Sep 2016 19:13:33 -0700
Subject: [PATCH] tests/fmbtest: avoid false-failure due to reliance on
 MB-correct sed

* tests/fmbtest: Several of these tests would mistakenly fail due to
postprocessing with a combination of sed and locale support that failed
to handle some multibyte characters in the cs_CZ.UTF-8 locale.  Instead
of relying on sed's multibyte support or anything locale-related to
perform this simple filtering, just use this: tr -cs '0-9' '[ *]'
Also, rather than exporting LC_ALL, just set it for each command.
Reported by Nelson H. F. Beebe.
---
 tests/fmbtest | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/tests/fmbtest b/tests/fmbtest
index 6f60f03..14fb9d3 100755
--- a/tests/fmbtest
+++ b/tests/fmbtest
@@ -52,25 +52,22 @@ EOF

 for mode in F G E; do

-test1=$(echo $(LC_ALL=$cz; export LC_ALL
-               grep -${mode} -f cspatfile csinput |
-                 sed 's/[^0123456789]/ /g'))
+test1=$(echo $(LC_ALL=$cz grep -${mode} -f cspatfile csinput |
+               tr -cs '0-9' '[ *]'))
 if test "$test1" != "11 12 13 14 15 16 17 18"; then
   echo "Test #1 ${mode} failed: $test1"
   failures=1
 fi

-test2=$(echo $(LC_ALL=$cz; export LC_ALL
-               grep -${mode}i -f cspatfile csinput |
-                 sed 's/[^0123456789]/ /g'))
+test2=$(echo $(LC_ALL=$cz grep -${mode}i -f cspatfile csinput |
+               tr -cs '0-9' '[ *]'))
 if test "$test2" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
   echo "Test #2 ${mode} failed: $test2"
   failures=1
 fi

-test3=$(echo $(LC_ALL=$cz; export LC_ALL
-               grep -${mode}i -e 'ČÍšE' -e 'Čas' csinput |
-                 sed 's/[^0123456789]/ /g'))
+test3=$(echo $(LC_ALL=$cz grep -${mode}i -e 'ČÍšE' -e 'Čas' csinput |
+               tr -cs '0-9' '[ *]'))
 if test "$test3" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
   echo "Test #3 ${mode} failed: $test3"
   failures=1
@@ -117,9 +114,8 @@ done

 for mode in G E; do

-test8=$(echo $(LC_ALL=$cz; export LC_ALL
-               grep -${mode}i -e 'Č.šE' -e 'Č[a-f]s' csinput |
-                 sed 's/[^0123456789]/ /g'))
+test8=$(echo $(LC_ALL=$cz grep -${mode}i -e 'Č.šE' -e 'Č[a-f]s' csinput |
+               tr -cs '0-9' '[ *]'))
 if test "$test8" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
   echo "Test #8 ${mode} failed: $test8"
   failures=1
-- 
2.7.4

