File: max-count-overread

package info (click to toggle)
grep 3.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,556 kB
  • sloc: ansic: 111,824; sh: 13,272; perl: 606; makefile: 394; awk: 71; sed: 16
file content (31 lines) | stat: -rwxr-xr-x 843 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
# Ensure that -m1 stops reading after the first match.
# In grep-2.19, yes x|grep -m1 x would infloop.

. "${srcdir=.}/init.sh"; path_prepend_ ../src
require_timeout_

fail=0

echo x > exp || framework_failure_

yes x | timeout 10 grep -m1 x > out || fail=1
compare exp out || fail=1

# Make sure -m2 stops reading even when output is /dev/null.
# In grep 3.11, it would continue reading.
printf 'x\nx\nx\n' >in || framework_failure
(grep -m2 x >/dev/null && head -n1) <in >out || fail=1
compare exp out || fail=1

# The following two tests would fail before v3.11-70
echo x > in || framework_failure_
echo in > exp || framework_failure_
grep -l -m1 . in > out || fail=1
compare exp out || fail=1

# Ensure that this prints nothing and exits successfully.
grep -q -m1 . in > out || fail=1
compare /dev/null out || fail=1

Exit $fail