Subject: Re: bug#47023: df utilility displays G instead of GM as unit size for Gigabytes in power of 1000

From: Pádraig Brady <[email-masked]>
Date: Tue, 9 Mar 2021 19:51:45 +0000

unarchive 18119
forcemerge 18119 47023
stop

On 09/03/2021 12:58, Philippe Bénézech via GNU coreutils Bug Reports wrote:
> Dear maintener,
> 
> I found a reproducible bug in df utility, installed in debian stable
> 
> $ df --version |head -1
> df (GNU coreutils) 8.30
> $ cat /etc/debian_version
> 10.8
> 
> df displays G instead of GM as unit size for Gigabytes in power of 1000
> (but the value is correct)

This is not restricted to G

> $ df -BGB /home
> Sys. de fichiers blocs de 1GB Utilisé Disponible Uti% Monté sur
> /dev/mapper/ssd2        421GB   355GB       45GB  89% /home
> 
> $ df -H /home
> Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur
> /dev/mapper/ssd2   421G    355G   45G  89% /home

In summary df -H is outputting with a concise single letter,
which is indistinguishable from that of df -h.
I agree that's not ideal as the output can't be
interpreted without the command as context.
I.e. it restricts usage to direct command line usage.
A possible change we could make here would be to use GB, MB etc.
if --si is specified.
But also -h and -H are not really useful outside of direct cli usage,
I'm 50:50 on changing this.

This was originally discussed at https://bugs.gnu.org/18119

Mentioned there is an option to use the new numfmt functionality
to provide more control and unambiguous output.

BTW the fact that a B suffix implies SI units is awkward in the first place,
which I've documented the reasons for at:
https://www.pixelbeat.org/docs/coreutils-gotchas.html#units

cheers,
Pádraig