grep inconsistency when used on binary files omitting -a
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
grep (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: grep
Hello. I am about to use grep from my script on a binary stdin. the result I intend to receive from grep is actually text, and in most cases I get the result I want, but in some cases grep only prints
Binary file (standard input) matches
so it's some sort of inconsistency.
Well, adding -a to the command line is not only a workaround, so I'll do it, however this fact doesn't mean this inconsistency isn't a bug. It seems to me that bash launches the processes in different order/parallell
I'll attach testfiles to this bug report tomorrow
ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: grep 2.5.4-4build1
ProcVersionSign
Uname: Linux 2.6.32-
Architecture: i386
Date: Fri Jan 14 02:33:47 2011
InstallationMedia: Ubuntu 10.04 "Lucid Lynx" - Release Candidate i386 (20100419)
ProcEnviron:
PATH=(custom, user)
LANG=hu_HU.utf8
SHELL=/bin/bash
SourcePackage: grep
I can reproduce the bug with this testscript. It generates a testfile (if it doesn't exist) from /dev/urandom, as I noticed there are testfiles better than other testfiles to reproduce the bug. So if you don't manage to reproduce the bug after several tries (say, 30, this would be more than enough) remove the testfile, so the script can generate a new one.
The script refers to one result as expected result, while refers to the other result as the illustration of the bug. It's just what I happened to expect when I wrote my previous script, I do not want to suggest what should be returned by grep consistently. But, what I want to suggest is the result here should be consistent (so always the "buggy" one, or always the "expected" one). /tmp/testdir$ ls -A /tmp/testdir$ mcedit testscript.sh
imi@most:
testscript.sh
imi@most:
imi@most: /tmp/testdir$ ./testscript.sh /tmp/testdir$ ls -A /tmp/testdir$ ./testscript.sh /tmp/testdir$ ./testscript.sh /tmp/testdir$ rm testfile /tmp/testdir$ LANG=en_GB ./testscript.sh /tmp/testdir$ echo "Binary file (standard input) matches"|wc -c /tmp/testdir$ echo "(szabványos bemenet) bináris fájl illeszkedik"|wc -c /tmp/testdir$ LANG=en_GB ./testscript.sh /tmp/testdir$
got result: 19 -- expected result: 19
result is OK.
imi@most:
testfile testscript.sh
imi@most:
got result: 19 -- expected result: 19
result is OK.
imi@most:
got result: 49 -- expected result: 19
we've fetched the bug now!
please notice that 49 is the actual char count for the message (szabványos bemenet) bináris fájl illeszkedik
imi@most:
imi@most:
got result: 37 -- expected result: 19
we've fetched the bug now!
please notice that 37 is the actual char count for the message Binary file (standard input) matches
imi@most:
37
imi@most:
49
imi@most:
got result: 19 -- expected result: 19
result is OK.
imi@most:
you can watch the same session as a video here: http:// csomalin. csoma.elte. hu/~pentek_ i/grep_ bug.ogv
btw my default $LANG is: /tmp/testdir$ echo $LANG /tmp/testdir$
imi@most:
hu_HU.utf8
imi@most: