Subject: Re: bug#7176: Feature request: add option to display full units in -h and --si output

From: Pádraig Brady <[email-masked]>
Date: Fri, 08 Oct 2010 23:45:11 +0100

On 08/10/10 17:52, Mihai Capotă wrote:
> The output of -h or --si looks identical (if K/k doesn't show up). It
> would be useful to be able to differentiate between the two by having
> the full units in the output, e.g., MiB and MB, respectively, instead
> of just M.
> 
> Actually, the manual [1] does say "si is similar [to h], but uses
> powers of 1000 and appends ‘B’", but that seems to be a bug, as a
> similar wording in the ls manual was corrected [2].
> 
> Maybe there's a way to generate this full-unit output with the
> existing options, but I don't see it. Specifying a unit in
> --block-size (e.g., "MiB or MB") results in everything being displayed
> only in that unit, not in the usage of the whole spectrum of units, as
> with -h and --si.

Also there is some inconsistency in how specified units are handled
pb-laptop:~$ BLOCKSIZE=1K df .
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda5              5034364   4815560    167700  97% /
pb-laptop:~$ BLOCKSIZE=K df .
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda5             5034364K  4815560K   167700K  97% /
pb-laptop:~$ BLOCKSIZE=Ki df .
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda5              5034364   4815560    167700  97% /
pb-laptop:~$ BLOCKSIZE=KiB df .
Filesystem         1KiB-blocks      Used Available Use% Mounted on
/dev/sda5            5034364KiB 4815560KiB 167700KiB  97% /
pb-laptop:~$ BLOCKSIZE=k df .
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda5             5034364K  4815560K   167700K  97% /

We must look into that.

> 
> I see two possible solutions:
> 
> (1) add a new flag, say --full-units
> (2) add two more options for --block-size, say "decimal" and "binary"

(3) get "1024" mode to always output the extra 'i'
But that would mean `ls -lh` would output the 'i' by default,
which I'm not sure is acceptable.

I think (2) is a good option.

Though in saying that, supporting this isn't that
important I think, as the relative sizes are what's important
given that the values are truncated in any case.
So I'm 50:50 about making that change.

cheers,
Pádraig.