Last change
on this file was 3529, checked in by bird, 3 years ago |
Imported grep 3.7 from grep-3.7.tar.gz (sha256: c22b0cf2d4f6bbe599c902387e8058990e1eee99aef333a203829e5fd3dbb342), applying minimal auto-props.
|
-
Property svn:executable
set to
*
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/bin/sh
|
---|
2 | # Demonstrate the disk-filling infloop when redirecting to an input file.
|
---|
3 | . "${srcdir=.}/init.sh"; path_prepend_ ../src
|
---|
4 | require_timeout_
|
---|
5 |
|
---|
6 | # Use an input file large enough that the problem is reproducible in spite
|
---|
7 | # of buffering effects. Just larger than 256KB should be adequate.
|
---|
8 | v=$(printf %063d 0)'
|
---|
9 | '
|
---|
10 | # 64 * 2^12 = 256k
|
---|
11 | for i in 1 2 3 4 5 6 7 8 9 10 11 12; do
|
---|
12 | v="$v$v"
|
---|
13 | done
|
---|
14 |
|
---|
15 | echo "$v" > out || framework_failure_
|
---|
16 |
|
---|
17 | for arg in out - ''; do
|
---|
18 | # Accommodate both 'out' and '(standard input)', as well as
|
---|
19 | # the multi-byte quoting we see on OS/X-based systems.
|
---|
20 | echo grep: ...: input file is also the output > err.exp || framework_failure_
|
---|
21 |
|
---|
22 | # Require an exit status of 2.
|
---|
23 | # grep-2.8 and earlier would infloop with $arg = out.
|
---|
24 | # grep-2.10 and earlier would infloop with $arg = - or $arg = ''.
|
---|
25 | timeout 10 grep 0 $arg < out >> out 2> err; st=$?; test $st = 2 || fail=1
|
---|
26 | sed 's/grep: .*: /grep: ...: /' err > k && mv k err
|
---|
27 | # Normalize the diagnostic prefix from e.g., "/mnt/dir/grep: " to "grep: "
|
---|
28 | sed 's/^[^:]*: /grep: /' err > k && mv k err
|
---|
29 | compare err.exp err || fail=1
|
---|
30 |
|
---|
31 | # But with each of the following options it must not exit-2.
|
---|
32 | for i in -q -m1 -l -L; do
|
---|
33 | timeout 10 grep $i 0 $arg < out >> out 2> err; st=$?
|
---|
34 | test $st = 2 && fail=1
|
---|
35 | done
|
---|
36 |
|
---|
37 | timeout 10 grep -2 0 $arg < out >> out 2> err; st=$?
|
---|
38 | test $st = 2 || fail=1
|
---|
39 | done
|
---|
40 |
|
---|
41 | Exit $fail
|
---|
Note:
See
TracBrowser
for help on using the repository browser.