On 08/01/2012 08:28 AM, Martin Carroll wrote: > Hi Paul, > >> The same idea would apply to other tools that >> want to do something special for binary versus >> text files. > > The problem, as I'm sure you know, is that unix intentionally > does not differentiate ascii from binary files,
Actually, POSIX does differentiate. There are several requirements in POSIX that state that tools may (or even must) behave differently on binary files (any file with a NUL byte, and any file not ending in a newline) when compared to text files (no NUL bytes, and last byte is a newline). >> If I type 'grep -rw 'open' *', I don't want to see >> all the strings containing 'open' in random *.o files >> that happen to be lying around > > Why do you prefer > > Binary file matches > > over > > [binary data]an occurence of open[binary data] > [binary data]another occurence of open[binary data] POSIX only requires 'grep' to behave sanely on text files. The moment you throw a binary file at grep, all bets are off, according to the standards. Sometimes, even the one-liner 'Binary file matches' is nicer output than listing multiple matches, even if we do add an option to munge the binary data to at least not corrupt the terminal. -- Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
