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:
954 bytes
|
Line | |
---|
1 | #!/bin/sh
|
---|
2 | # Check that a write failure with errno == EPIPE
|
---|
3 | # doesn't cause grep to issue multiple "write error" diagnostics.
|
---|
4 |
|
---|
5 | . "${srcdir=.}/init.sh"; path_prepend_ ../src
|
---|
6 |
|
---|
7 | if
|
---|
8 | # Use awk to output a bounded amount of data to the grep in question,
|
---|
9 | # so that the test doesn't loop forever if grep is buggy.
|
---|
10 | # Use an explicit /dev/null for the benefit of older (pre-POSIX) awks.
|
---|
11 | #
|
---|
12 | # Carefully close fd 3 when not needed, as a sanity check.
|
---|
13 | #
|
---|
14 | # Do not use "trap - PIPE" or "trap 'something' PIPE" here, since we may
|
---|
15 | # be running in an environment where SIGPIPE is ignored, and in such an
|
---|
16 | # environment POSIX says that "trap '' PIPE" is all we can do portably.
|
---|
17 | (
|
---|
18 | ${AWK-awk} 'BEGIN { for (i=0; i<1000000; i++) print i; }' /dev/null 3>&- |
|
---|
19 | (trap '' PIPE; exec grep . 2>&3 3>&-) |
|
---|
20 | :
|
---|
21 | ) 3>&1 | (
|
---|
22 | read line1 && echo >&2 "$line1" &&
|
---|
23 | read line2 && echo >&2 "$line2"
|
---|
24 | )
|
---|
25 | then fail=1
|
---|
26 | else fail=0
|
---|
27 | fi
|
---|
28 |
|
---|
29 | Exit $fail
|
---|
Note:
See
TracBrowser
for help on using the repository browser.