bug-grep
[Top][All Lists]
Advanced

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

Re: SEEK_HOLE defined but useless on linux-3.4+/ext4 [Re: small ascii fi


From: Eric Blake
Subject: Re: SEEK_HOLE defined but useless on linux-3.4+/ext4 [Re: small ascii files can be sparse
Date: Wed, 01 Aug 2012 08:42:22 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0

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   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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