Debian Codegraph @

tests/options

raw
1 #! /bin/sh
2 # Test for POSIX options for grep
3 #
4 # Copyright (C) 2001, 2006, 2009-2025 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 # grep [ -E| -F][ -c| -l| -q ][-insvx] -e pattern_list
11 # [-f pattern_file] ... [file. ..]
12 # grep [ -E| -F][ -c| -l| -q ][-insvx][-e pattern_list]
13 # -f pattern_file ... [file ...]
14 # grep [ -E| -F][ -c| -l| -q ][-insvx] pattern_list [file...]
15
16 . "${srcdir=.}/init.sh"; path_prepend_ ../src
17
18 fail=0
19
20 # checking for -E extended regex
21 echo "abababccccccd" | grep -E -e 'c{3}' > /dev/null 2>&1
22 if test $? -ne 0 ; then
23 echo "Options: Wrong status code, test #1 failed"
24 fail=1
25 fi
26
27 # checking for basic regex
28 echo "abababccccccd" | grep -G -e 'c\{3\}' > /dev/null 2>&1
29 if test $? -ne 0 ; then
30 echo "Options: Wrong status code, test #2 failed"
31 fail=1
32 fi
33
34 # checking for fixed string
35 echo "abababccccccd" | grep -F -e 'c\{3\}' > /dev/null 2>&1
36 if test $? -ne 1 ; then
37 echo "Options: Wrong status code, test #3 failed"
38 fail=1
39 fi
40
41 # checking for multiple -e options; see:
42 # https://bugs.gnu.org/21670
43 echo abchelloabc | grep -e '^hello' -e 'hello$' > /dev/null 2>&1
44 if test $? -ne 1 ; then
45 echo "Options: Wrong status code, test #4 failed"
46 fail=1
47 fi
48
49 Exit $fail