On 11/19/2012 09:16 PM, Dennis Clarke wrote: > read(3, 0x100153764, 131072) Err#21 EISDIR
Thanks, that let me find the problem. I pushed the following patch into the grep master on savannah. Dunno if it applies to grep 2.13 exactly, but the fix should appear in the next release. It's a minor bug so I wouldn't worry about it in the meantime. >From a93b4736f3c732809db26f148721caf98d0b7211 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Mon, 19 Nov 2012 23:50:40 -0800 Subject: [PATCH] grep: diagnose read errors from -f dir, porting to Solaris Problem reported by Dennis Clarke for Solaris 10 in <http://lists.gnu.org/archive/html/bug-grep/2012-11/msg00009.html>. * src/main.c (main): For -f F, diagnose any read errors encountered when reading F. * tests/Makefile.am (XFAIL_TESTS): Remove grep-dir. * tests/grep-dir: Don't assume that directories cannot be read via fread, as POSIX allows this and it can happen on Solaris. --- src/main.c | 7 +++++-- tests/Makefile.am | 3 +-- tests/grep-dir | 24 ++++++++++++++++-------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/main.c b/src/main.c index 6750007..cadefd6 100644 --- a/src/main.c +++ b/src/main.c @@ -1860,6 +1860,7 @@ main (int argc, char **argv) size_t cc; int opt, status, prepended; int prev_optind, last_recursive; + int fread_errno; intmax_t default_context; FILE *fp; exit_failure = EXIT_TROUBLE; @@ -2009,13 +2010,15 @@ main (int argc, char **argv) ; keys = xrealloc (keys, keyalloc); oldcc = keycc; - while (!feof (fp) - && (cc = fread (keys + keycc, 1, keyalloc - 1 - keycc, fp)) > 0) + while ((cc = fread (keys + keycc, 1, keyalloc - 1 - keycc, fp)) != 0) { keycc += cc; if (keycc == keyalloc - 1) keys = x2nrealloc (keys, &keyalloc, sizeof *keys); } + fread_errno = errno; + if (ferror (fp)) + error (EXIT_TROUBLE, fread_errno, "%s", optarg); if (fp != stdin) fclose (fp); /* Append final newline if file ended in non-newline. */ diff --git a/tests/Makefile.am b/tests/Makefile.am index 2f99a69..7565840 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -24,8 +24,7 @@ LDADD = ../lib/libgreputils.a $(LIBINTL) ../lib/libgreputils.a # Remove this definition once the failing test passes. XFAIL_TESTS = \ - word-delim-multibyte \ - grep-dir + word-delim-multibyte # Equivalence classes are only supported when using the system # matcher (which means only with glibc). diff --git a/tests/grep-dir b/tests/grep-dir index e005525..de14d62 100755 --- a/tests/grep-dir +++ b/tests/grep-dir @@ -4,14 +4,22 @@ mkdir a || framework_failure -echo x | grep -f a/; { test $? -gt 1 && test $? -lt 128; } || fail=1 -echo x | grep -if a/; { test $? -gt 1 && test $? -lt 128; } || fail=1 -echo x | grep -Ff a/; { test $? -gt 1 && test $? -lt 128; } || fail=1 -echo x | grep -Fif a/; { test $? -gt 1 && test $? -lt 128; } || fail=1 +# Lower and upper bound of valid exit status for "grep -f DIR", +# when reading from empty and nonempty files, respectively. +if cat a >/dev/null 2>&1; then + l=1 u=1 L=0 U=1 +else + l=2 u=127 L=2 U=127 +fi -grep -f a/ < /dev/null; { test $? -gt 1 && test $? -lt 128; } || fail=1 -grep -if a/ < /dev/null; { test $? -gt 1 && test $? -lt 128; } || fail=1 -grep -Ff a/ < /dev/null; { test $? -gt 1 && test $? -lt 128; } || fail=1 -grep -Fif a/ < /dev/null; { test $? -gt 1 && test $? -lt 128; } || fail=1 +echo x | grep -f a/; { test $? -ge $L && test $? -le $U; } || fail=1 +echo x | grep -if a/; { test $? -ge $L && test $? -le $U; } || fail=1 +echo x | grep -Ff a/; { test $? -ge $L && test $? -le $U; } || fail=1 +echo x | grep -Fif a/; { test $? -ge $L && test $? -le $U; } || fail=1 + +grep -f a/ < /dev/null; { test $? -ge $l && test $? -le $u; } || fail=1 +grep -if a/ < /dev/null; { test $? -ge $l && test $? -le $u; } || fail=1 +grep -Ff a/ < /dev/null; { test $? -ge $l && test $? -le $u; } || fail=1 +grep -Fif a/ < /dev/null; { test $? -ge $l && test $? -le $u; } || fail=1 Exit $fail -- 1.7.11.7
