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 09:45:10 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

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
> 
> This works the same on all unix systems.
> What would changing base provide except ambiguity?

The behavior of -l (--verbose) is mandated by POSIX:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cmp.html
> When the -l option is used, the format shall be:
> 
> "%d %o %o\n", <byte number>, <differing byte>,
>     <differing byte>

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

Also, POSIX allows us to write this as:

  9 0141 0142
 11 0143 0142

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap05.html
> If both the field width and precision are omitted, the implementation may 
> precede, follow, or precede and follow numeric arguments of types d, i, and u 
> with <blank> characters; arguments of type o (octal) may be preceded with 
> leading zeros.

So we would still be compliant if we tweaked the output to make it more
blatantly obvious that we are outputting octal character values.

-- 
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]