FS#42940 - [grep] 2.21 gives no useful output; faulty considers everything binary; -c gives wrong counts

Attached to Project: Arch Linux
Opened by Hans Pelleboer (hansp) - Friday, 28 November 2014, 14:16 GMT
Last edited by Sébastien Luttringer (seblu) - Tuesday, 17 February 2015, 00:12 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Sébastien Luttringer (seblu)
Architecture x86_64
Severity Low
Priority Low
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description:

After upgrading to grep V2.21 yesterday I noticed that,
no matter what combination of input flags I use, grep outputs
whenever it finds a match only this: Binary file <SSSSS> matches.
This is independent of <SSSSS> actually being binary or not.
When presented with the -c flag, grep prints a `1', independent
of the number of matches present in the search file.

Its 'null' behaviour is as usual: no match, no output.

I had an archived grep V2.20 around; after placing this in /usr/bin
grep behaved normal again; glibc, among others, got upgraded yesterday
as well, so I feared this to be a faulty glibc dependency. Evidently,
it isn't.

Additional info:
* package version(s) V2.21
* config and/or log files etc.


Steps to reproduce:
invoke grep with -c, -i, -e, -f, -n, -A or combinations thereof
yields the faulty behaviour described above
This task depends upon

Closed by  Sébastien Luttringer (seblu)
Tuesday, 17 February 2015, 00:12 GMT
Reason for closing:  Upstream
Additional comments about closing:  Reopen if upstream provide a fix
Comment by Sébastien Luttringer (seblu) - Friday, 28 November 2014, 19:45 GMT
I'm not able to reproduce

$ grep -V|head -n1
grep (GNU grep) 2.21
$ grep -c bash /etc/passwd
5
$ grep root /etc/passwd
root:x:0:0:Charlie Rwolf Root:/root:/bin/zsh
$ grep ELF /usr/bin/bash
Binary file /usr/bin/bash matches
Comment by Hans Pelleboer (hansp) - Friday, 28 November 2014, 20:07 GMT
In response, I removed the functioning V2.20, and reinstalled V2.21.
The problem has shifted somewhat: the -c flag seems to be functioning,
but a simple string search is still unsuccesful, unless the -a flag is used.
Can it be that the default behaviour of grep has shifted from -a to -I ?
That would explain it. If so --how can I change grep's defaults?
Comment by Hans Pelleboer (hansp) - Friday, 28 November 2014, 21:50 GMT
The pathology seems to be centered around a few specific files.
I can't find out what is wrong with them; none of the usual aberrations
are there, e.g. <CR><LF> deviations. Still, grep 2.21 insists that the
files are binary. I would like to include one, provided that you delete
it after use. It's my personal adress file, originally created in 1986
on the very first unix machine I worked on. A grep oneliner allows me
to retrieve adresses and perform range searches.
It remains peculiar, that all greps until now but this one have read
this file without fail.
Would you like to use this file for testing?
Comment by Sébastien Luttringer (seblu) - Friday, 28 November 2014, 22:04 GMT
hansp, your issue seems to be specific and you should open a bug report to grep upstream. They are the best person to fix their software.
Comment by Mr Weatherbee (MrWeatherbee) - Friday, 28 November 2014, 22:41 GMT
I wrote a lengthy post this morning (when this bug had no comments) hoping to shed some
light on my grep issue before signing up to flyspray:

https://bbs.archlinux.org/viewtopic.php?id=190436

However, since this seems destined for upstream, I thought I'd at least point out here that:

- this bug impacts rkhunter. For example, the rkhunter update-process uses grep to determine
file versions, and it fails on some files with grep 2.21 but succeeds with 2.20 and earlier
grep versions.

- grep 2.21 succeeds on ASCII text files but fails on ISO-8859 text files (unless the '-a' option is used).
Grep v2.20 does not require the '-a' on the ISO-8859 text files.

It may be possible that other encodings give grep v2.21 problems.
Comment by Sébastien Luttringer (seblu) - Sunday, 30 November 2014, 12:50 GMT
hansp, could you point the link of the upstream bug report here?
Comment by Hans Pelleboer (hansp) - Monday, 01 December 2014, 08:04 GMT
This has become grep bug #19230

The issue seems to be locale dependent; when set to UTF-8, ISO-8859 is no longer
recognized. I am trying to finagle what can be done, to keep grep
more accepting. After all, editors and the like don't act that difficult,
as a rule, when presented with different encodings.

Loading...