| 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-2021 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 "" | 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 | 
 | 
|---|
| 49 |         # should return 0 found a match
 | 
|---|
| 50 |         echo abcd | LC_ALL=$locale timeout 10s grep $options -e ''
 | 
|---|
| 51 |         if test $? -ne 0 ; then
 | 
|---|
| 52 |           echo "Status: Wrong status code, test \#5 failed ($options $locale)"
 | 
|---|
| 53 |           failures=1
 | 
|---|
| 54 |         fi
 | 
|---|
| 55 |     done
 | 
|---|
| 56 | 
 | 
|---|
| 57 |     for options in '-E -w' '-E -x' '-E -w -x' '-F -w' '-F -x' '-F -w -x'; do
 | 
|---|
| 58 | 
 | 
|---|
| 59 |         # should return 0 found a match
 | 
|---|
| 60 |         echo "" | LC_ALL=$locale timeout 10s grep $options -e ''
 | 
|---|
| 61 |         if test $? -ne 0 ; then
 | 
|---|
| 62 |           echo "Status: Wrong status code, test \#6 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
 | 
|---|
| 68 |         if test $? -ne 1 ; then
 | 
|---|
| 69 |           echo "Status: Wrong status code, test \#7 failed ($options $locale)"
 | 
|---|
| 70 |           failures=1
 | 
|---|
| 71 |         fi
 | 
|---|
| 72 | 
 | 
|---|
| 73 |         # should return 1 found no match
 | 
|---|
| 74 |         echo abcd | LC_ALL=$locale timeout 10s grep $options -f /dev/null -e ""
 | 
|---|
| 75 |         if test $? -ne 1 ; then
 | 
|---|
| 76 |           echo "Status: Wrong status code, test \#8 failed ($options $locale)"
 | 
|---|
| 77 |           failures=1
 | 
|---|
| 78 |         fi
 | 
|---|
| 79 |     done
 | 
|---|
| 80 | done
 | 
|---|
| 81 | 
 | 
|---|
| 82 | Exit $failures
 | 
|---|