coreutils
[Top][All Lists]
Advanced

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

Re: Feature Request - CMP


From: Eric Blake
Subject: Re: Feature Request - CMP
Date: Fri, 06 Feb 2015 10:07:33 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

On 02/06/2015 09:45 AM, Eric Blake wrote:
> On 02/06/2015 09:23 AM, Pádraig Brady wrote:
>> On 06/02/15 15:57, Tyler Beaver wrote:
>>> I know this tool is probably note used as much anymore, but perhaps it 
>>> would be worth adding a flag for overriding the verbose output number 
>>> system for the values, or at any rate specifying that this output is in 
>>> octal, and not decimal or hexadecimal.
>>
>> Currently: offsets are decimal, differing bytes are octal:
>>
>>   $ cmp -l <(echo 12345678abc) <(echo 12345678bbb)
>>                     9 141 142
>>                    11 143 142

Another observation: Note that when mixed with --ignore-initial, we
behave as if offsets start from the point where we skipped to, rather
than the beginning of the file.  Since -i is not required by POSIX, does
this always make the most sense?

$ cmp -l     <(printf bbc) <(printf abd)
                  1 142 141
                  3 143 144
$ cmp -l -i1 <(printf bbc) <(printf abd)
                  2 143 144

and what happens when we use the two-offset form?

$ cmp -l -i2:1 <(printf abcd) <(printf bce)
                  2 144 145
$ cmp -l -i1:2 <(printf bce) <(printf abcd)
                  2 145 144


> That said, it might be worth patching 'cmp --help' to make it obvious
> that differing bytes are in octal values.

That is, instead of

  -l, --verbose              output byte numbers and differing byte values

maybe we could use:

  -l, --verbose              for each difference, output the decimal
                             offset and the differing octal values

Expanding that to two lines can be offset by compressing elsewhere:

  -i, --ignore-initial=SKIP         skip first SKIP bytes of both inputs
  -i, --ignore-initial=SKIP1:SKIP2  skip first SKIP1 bytes of FILE1 and
                                      first SKIP2 bytes of FILE2

feels long; how about:

  -i, --ignore-initial=SKIP[:SKIP2]  bypass SKIP bytes of FILE1, and
                                     SKIP2 (default SKIP) bytes of FILE2

-- 
Eric Blake   eblake redhat com    +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]