bug-gnu-utils
[Top][All Lists]
Advanced

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

GNU grep behavior


From: Dave Hines
Subject: GNU grep behavior
Date: Wed, 25 Aug 2004 14:02:59 +0100
User-agent: KMail/1.5.4

Hi there,
          I have recently updated from using an old version of GNU grep
to version 2.5.1, and found that it has changed its behavior in such a
way that it breaks some scripts.

I had been using grep to select some lines from a small block of data
which happens to contain a zero byte after the last line. In the past
this worked, but with the newer grep the wanted output is not given,
and a message saying that a binary file matches is given instead, from
the source line in grep.c:
        printf (_("Binary file %s matches\n"), filename);

Although I see that an option (-a, --text, --binary-files=text) exist to
change this, I think that the new grep is wrong for two reasons:

1) Effort should be made not to break things when changes are made.
   The old behavior should be retained as the default case, and new
   behavior should be enabled by a switch, not disabled. (I have always
   been annoyed by software that thinks it knows better than I do,
   especially when it is wrong).

2) The "Binary file %s matches\n" message should be sent to stderr,
   not stdout. The output of grep is supposed to be lines selected from
   the input, which that message is not. Messages about the behavior of
   grep, unexpected inputs etc. should not appear on stdout, but go to
   stderr. In the case of my scripts which this change broke, the output
   of grep was being piped into another programme, so I didn't see the
   message - it just caused more trouble to the next process.

Regards -- Dave Hines.





reply via email to

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