Last change
on this file since 3627 was 2595, checked in by bird, 13 years ago |
gnu grep version 2.12 (grep-2.12.tar.xz, md5sum=8d2f0346d08b13c18afb81f0e8aa1e2f)
|
File size:
1.2 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/file .* is/file ... is/' err > k && mv k err
|
---|
27 | compare err.exp err || fail=1
|
---|
28 |
|
---|
29 | # But with each of the following options it must not exit-2.
|
---|
30 | for i in -q -m1 -l -L; do
|
---|
31 | timeout 10 grep $i 0 $arg < out >> out 2> err; st=$?
|
---|
32 | test $st = 2 && fail=1
|
---|
33 | done
|
---|
34 |
|
---|
35 | timeout 10 grep -2 0 $arg < out >> out 2> err; st=$?
|
---|
36 | test $st = 2 || fail=1
|
---|
37 | done
|
---|
38 |
|
---|
39 | Exit $fail
|
---|
Note:
See
TracBrowser
for help on using the repository browser.