| 1 | #! /bin/sh
|
|---|
| 2 | # Test grep's behavior on encoding errors.
|
|---|
| 3 | #
|
|---|
| 4 | # Copyright 2015-2021 Free Software Foundation, Inc.
|
|---|
| 5 | #
|
|---|
| 6 | # Copying and distribution of this file, with or without modification,
|
|---|
| 7 | # are permitted in any medium without royalty provided the copyright
|
|---|
| 8 | # notice and this notice are preserved.
|
|---|
| 9 |
|
|---|
| 10 | . "${srcdir=.}/init.sh"; path_prepend_ ../src
|
|---|
| 11 |
|
|---|
| 12 | require_en_utf8_locale_
|
|---|
| 13 |
|
|---|
| 14 | printf 'Alfred Jones\n' > a || framework_failure_
|
|---|
| 15 | printf 'John Smith\n' >j || framework_failure_
|
|---|
| 16 | printf 'Pedro P\351rez\n' >p || framework_failure_
|
|---|
| 17 | cat a p j >in || framework_failure_
|
|---|
| 18 |
|
|---|
| 19 | LC_ALL=en_US.UTF-8
|
|---|
| 20 | export LC_ALL
|
|---|
| 21 |
|
|---|
| 22 | fail=0
|
|---|
| 23 |
|
|---|
| 24 | grep '^A' in >out || fail=1
|
|---|
| 25 | compare a out || fail=1
|
|---|
| 26 |
|
|---|
| 27 | grep '^P' in >out || fail=1
|
|---|
| 28 | compare /dev/null out || fail=1
|
|---|
| 29 |
|
|---|
| 30 | grep -I '^P' in >out 2>err || fail=1
|
|---|
| 31 | compare /dev/null out || fail=1
|
|---|
| 32 | compare /dev/null err || fail=1
|
|---|
| 33 |
|
|---|
| 34 | grep '^J' in >out || fail=1
|
|---|
| 35 | compare j out || fail=1
|
|---|
| 36 |
|
|---|
| 37 | returns_ 1 grep '^X' in >out || fail=1
|
|---|
| 38 | compare /dev/null out || fail=1
|
|---|
| 39 |
|
|---|
| 40 | grep . in >out || fail=1
|
|---|
| 41 | cat a j >exp || framework_failure_
|
|---|
| 42 | compare exp out || fail=1
|
|---|
| 43 |
|
|---|
| 44 | grep -I . in >out 2>err || fail=1
|
|---|
| 45 | cat a j >exp || framework_failure_
|
|---|
| 46 | compare exp out || fail=1
|
|---|
| 47 | compare /dev/null err || fail=1
|
|---|
| 48 |
|
|---|
| 49 | grep -a . in >out || fail=1
|
|---|
| 50 | compare in out
|
|---|
| 51 |
|
|---|
| 52 | Exit $fail
|
|---|