summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-12-25 14:40:11 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2019-12-25 14:40:55 -0800
commitbf5a308349fbcf0a376ca3e6e83fe7c6a2cc9eb1 (patch)
treed31b61abd43928e37c14c45bc42b6ab8bf1f5651
parent6b4ee2c0b163de6fdac2dca6ddca6d3065d45bcd (diff)
downloadgrep-bf5a308349fbcf0a376ca3e6e83fe7c6a2cc9eb1.tar.gz
tests: work around AIX 7.2 sh printf bug
AIX 7.2 /bin/sh’s printf command mishandles octal escapes in multibyte locales: it treats them as characters, not bytes. * tests/backslash-s-vs-invalid-multitype, tests/encoding-error: Use the C locale when employing the printf command with an octal escape that AIX 7.2 sh might mishandle. * tests/init.sh (setup_): Use the C locale for tests. This has the side benefit of making them more reproducible.
-rwxr-xr-xtests/backslash-s-vs-invalid-multitype4
-rwxr-xr-xtests/encoding-error6
-rw-r--r--tests/init.sh2
3 files changed, 7 insertions, 5 deletions
diff --git a/tests/backslash-s-vs-invalid-multitype b/tests/backslash-s-vs-invalid-multitype
index 82c6e631..bfa44621 100755
--- a/tests/backslash-s-vs-invalid-multitype
+++ b/tests/backslash-s-vs-invalid-multitype
@@ -11,11 +11,11 @@
require_en_utf8_locale_
+printf '\202\n' > in || framework_failure_
+
LC_ALL=en_US.UTF-8
export LC_ALL
-printf '\202\n' > in || framework_failure_
-
fail=0
grep '^\S$' in > out-S && fail=1
compare /dev/null out-S || fail=1
diff --git a/tests/encoding-error b/tests/encoding-error
index 1987f09c..508206d0 100755
--- a/tests/encoding-error
+++ b/tests/encoding-error
@@ -11,14 +11,14 @@
require_en_utf8_locale_
-LC_ALL=en_US.UTF-8
-export LC_ALL
-
printf 'Alfred Jones\n' > a || framework_failure_
printf 'John Smith\n' >j || framework_failure_
printf 'Pedro P\351rez\n' >p || framework_failure_
cat a p j >in || framework_failure_
+LC_ALL=en_US.UTF-8
+export LC_ALL
+
fail=0
grep '^A' in >out || fail=1
diff --git a/tests/init.sh b/tests/init.sh
index 8ca5c905..a0ee8a9b 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -378,6 +378,8 @@ testdir_prefix_ () { printf gt; }
# Set up the environment for the test to run in.
setup_ ()
{
+ export LC_ALL=C
+
if test "$VERBOSE" = yes; then
# Test whether set -x may cause the selected shell to corrupt an
# application's stderr. Many do, including zsh-4.3.10 and the /bin/sh