--- /dev/null
+#!/bin/sh
+# Ensure that zgrep -f - works like grep -f -
+# Before gzip-1.4, it would fail.
+
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# limit so don't run it by default.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ zgrep --version
+fi
+
+. $srcdir/tests/test-lib.sh
+
+echo needle > n || framework_failure
+echo needle > haystack || framework_failure
+gzip haystack || framework_failure
+
+
+fail=0
+zgrep -f - haystack.gz < n > out 2>&1 || fail=1
+
+compare out n || fail=1
+
+Exit $fail
case $optarg in
(" '-'" | " '/dev/stdin'" | " '/dev/fd/0'")
pat_on_stdin=1
+ eval 'test -e .' 2>/dev/null \
+ && eval 'exists(){ test -e "$@"; }' \
+ || eval 'exists(){ test -r "$@" || test -w "$@"; }'
# Start search from 6 since the script already uses 3 and 5
- for fd in $(seq 6 254); do
- if test ! -e /dev/fd/$fd; then
- pat_fd=$fd
- break;
- fi
+ fd=6
+ pat_fd=
+ while : ; do
+ if ! exists /proc/$$/fd/$fd; then
+ pat_fd=$fd
+ break;
+ fi
+ fd=$(expr $fd + 1)
+ if test $fd = 255; then
+ printf >&2 '%s: no free file descriptor\n' "$0"
+ exit 2
+ fi
done
optarg=/dev/fd/$pat_fd;
esac