GNU bug report logs -
#23562
grep seems to write some error messages to stdout data stream --- shouldn't it be to stderr?
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23562 in the body.
You can then email your comments to 23562 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-grep <at> gnu.org
:
bug#23562
; Package
grep
.
(Tue, 17 May 2016 06:31:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"John Refling" <netbsdrat <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-grep <at> gnu.org
.
(Tue, 17 May 2016 06:31:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I noticed this when I had an issue with 'binary file detection' discussed
in bug report #22838.
In 2.24 when the binary file detection triggered, not only was some of my
output data missing (since processing stopped), there was no error message
since grep sent that error message to stdout, along with part of my data. I
was piping the output to another process.
I just built latest 2.25, and the binary file detection is improved, but the
error message STILL is hidden, since it is sent to redirected stdout, along
with data. Verified by building 2.25 on Cygwin and FreeBSD.
A contrived example:
server-grep-2.25> ./src/grep.exe . src/grep.exe > x
server-grep-2.25> cat x
Binary file src/grep.exe matches
IMHO, error messages should NEVER be injected into the same stream as the
users input / output data, firstly because it corrupts the data, and
secondly if the output is redirected, the user will never see the error
message.
Not sure if this affects all error messages, or just the 'Binary file FOO
matches' message.
Relevant areas of src/grep.c are:
printf_errno (_("Binary file %s matches\n"), filename);
printf_errno (char const *format, ...)
{
va_list ap;
va_start (ap, format);
if (vfprintf (stdout, format, ap) < 0) // should be stderr IMHO
stdout_errno = errno;
va_end (ap);
}
Seems to me that grep should NEVER add more data to the output stream than
was in the input stream (by adding anything, including error messages).
Just seems wrong.
Shouldn't there be exactly the same or less data, and not new data in the
output that was not even part of the original input data?
My 2 cents,
John Refling
Information forwarded
to
bug-grep <at> gnu.org
:
bug#23562
; Package
grep
.
(Tue, 17 May 2016 06:46:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 23562 <at> debbugs.gnu.org (full text, mbox):
John Refling wrote:
> Binary file src/grep.exe matches
>
> ... error messages should NEVER be injected into the same stream as the
> users input / output dat
It's not an error message.
> grep should NEVER add more data to the output stream than
> was in the input stream
grep has always done that sort of thing. E.g., grep has put file names into the
output stream ever since the 1970s.
Perhaps there should be an option for 'grep' to treat binary matches as errors
and to issue diagnostics on stderr rather than issue info on stdout. That being
said, the current behavior is useful too, and has been in place since the 1990s,
and changes in this area should not be made casually.
Severity set to 'wishlist' from 'normal'
Request was from
Paul Eggert <eggert <at> cs.ucla.edu>
to
control <at> debbugs.gnu.org
.
(Thu, 08 Sep 2016 08:25:02 GMT)
Full text and
rfc822 format available.
Reply sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
You have taken responsibility.
(Tue, 22 Sep 2020 19:05:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
"John Refling" <netbsdrat <at> gmail.com>
:
bug acknowledged by developer.
(Tue, 22 Sep 2020 19:05:02 GMT)
Full text and
rfc822 format available.
Message #15 received at 23562-done <at> debbugs.gnu.org (full text, mbox):
On 5/16/16 11:03 PM, John Refling wrote:
> error messages should NEVER be injected into the same stream as the
> users input / output data, firstly because it corrupts the data, and
> secondly if the output is redirected, the user will never see the error
> message.
On further thought (and after getting other bug reports) you make a good point,
and GNU grep's binary-file diagnostics will be sent to stderr instead of stdout
starting with the next release. See:
https://git.savannah.gnu.org/cgit/grep.git/commit/?id=271793f09cc604ad54ad89b18110716555cc748b
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 21 Oct 2020 11:24:07 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 years and 246 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.