| 1 |
#! /bin/sh |
| 2 |
# test that the empty file means no pattern |
| 3 |
# and an empty pattern means match all. |
| 4 |
# |
| 5 |
# Copyright (C) 2001, 2006, 2009-2025 Free Software Foundation, Inc. |
| 6 |
# |
| 7 |
# Copying and distribution of this file, with or without modification, |
| 8 |
# are permitted in any medium without royalty provided the copyright |
| 9 |
# notice and this notice are preserved. |
| 10 |
|
| 11 |
. "${srcdir=.}/init.sh"; path_prepend_ ../src |
| 12 |
|
| 13 |
require_timeout_ |
| 14 |
|
| 15 |
failures=0 |
| 16 |
|
| 17 |
for locale in C en_US.UTF-8; do |
| 18 |
for options in '-E' '-F'; do |
| 19 |
|
| 20 |
# should return 0 found a match |
| 21 |
echo "" | LC_ALL=$locale timeout 10s grep $options -e '' |
| 22 |
if test $? -ne 0 ; then |
| 23 |
echo "Status: Wrong status code, test \#1 failed ($options $locale)" |
| 24 |
failures=1 |
| 25 |
fi |
| 26 |
|
| 27 |
# should return 1 found no match |
| 28 |
echo abcd | LC_ALL=$locale timeout 10s grep $options -f /dev/null |
| 29 |
if test $? -ne 1 ; then |
| 30 |
echo "Status: Wrong status code, test \#2 failed ($options $locale)" |
| 31 |
failures=1 |
| 32 |
fi |
| 33 |
|
| 34 |
# should return 0 found a match |
| 35 |
echo abcd \ |
| 36 |
| LC_ALL=$locale timeout 10s grep $options -f /dev/null -e abcd |
| 37 |
if test $? -ne 0 ; then |
| 38 |
echo "Status: Wrong status code, test \#3 failed ($options $locale)" |
| 39 |
failures=1 |
| 40 |
fi |
| 41 |
|
| 42 |
# should return 0 found a match |
| 43 |
echo abcd | LC_ALL=$locale timeout 10s grep $options -e '' |
| 44 |
if test $? -ne 0 ; then |
| 45 |
echo "Status: Wrong status code, test \#4 failed ($options $locale)" |
| 46 |
failures=1 |
| 47 |
fi |
| 48 |
done |
| 49 |
|
| 50 |
for options in '-E -w' '-E -x' '-E -w -x' '-F -w' '-F -x' '-F -w -x'; do |
| 51 |
|
| 52 |
# should return 0 found a match |
| 53 |
echo "" | LC_ALL=$locale timeout 10s grep $options -e '' |
| 54 |
if test $? -ne 0 ; then |
| 55 |
echo "Status: Wrong status code, test \#6 failed ($options $locale)" |
| 56 |
failures=1 |
| 57 |
fi |
| 58 |
|
| 59 |
# should return 1 found no match |
| 60 |
echo abcd | LC_ALL=$locale timeout 10s grep $options -f /dev/null |
| 61 |
if test $? -ne 1 ; then |
| 62 |
echo "Status: Wrong status code, test \#7 failed ($options $locale)" |
| 63 |
failures=1 |
| 64 |
fi |
| 65 |
|
| 66 |
# should return 1 found no match |
| 67 |
echo abcd | LC_ALL=$locale timeout 10s grep $options -f /dev/null -e "" |
| 68 |
if test $? -ne 1 ; then |
| 69 |
echo "Status: Wrong status code, test \#8 failed ($options $locale)" |
| 70 |
failures=1 |
| 71 |
fi |
| 72 |
done |
| 73 |
done |
| 74 |
|
| 75 |
Exit $failures |