bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep . /; echo $?


From: Julian Foad
Subject: Re: grep . /; echo $?
Date: Fri, 04 Nov 2005 14:08:52 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511

Charles Levert wrote:

The following changed the logic slightly,
mostly so that read() errors on directories are
always ignored (not just when the user asked
for suppression), and that only the messages be
suppressed for non-directories (but not the >1
exit code).

] Working file: grep/src/grep.c
] ----------------------------
] revision 1.51
] date: 2001/02/08 16:12:10;  author: alainm;  state: Exp;  lines: +22 -12
] Exit status fix.
] ----------------------------
] No ChangeLog entry.

Huh. That's a useful log message - not. In fact, that change contains what I believe is the bug that caused directory read errors to be ignored, two further bugs, and an unrelated change. Good grief!


+/* Like error, but suppress the diagnostic if requested.  */
+static void
+suppressible_error (char const *mesg, int errnum)
+{
+  if (! suppress_errors)
+    error (mesg, errnum);
+  errseen = 1;
+}

(One of the further bugs is that "errseen" is only set for suppressible errors: that line was moved out of the general "error" function. This seems to have been subsequently fixed.)


-      if (! (is_EISDIR (errno, file) && suppress_errors))
-        error (filename, errno);
+      if (! is_EISDIR (errno, file))
+        suppressible_error (filename, errno);

The above change was made twice, and it causes directory errors to be always completely ignored, which I don't believe was the intent.

The other bug I see is in function grepfile(). After the change, if we're suppressing error messages, skipping a directory now sets "errseen".


I didn't find anything around those dates on
the mailing list (bug-gnu-utils, back then).

Thanks for doing this research.

It looks like we now have enough context to determine which aspects of the behaviour are bugs.

- Julian




reply via email to

[Prev in Thread] Current Thread [Next in Thread]