On 08/10/2025 13:00, Lukáš Zaoral wrote:
Hello,
we have an RFE in RHEL (the ticket is, unfortunately, private) to make the
ceiling provided by the human_readable function from gnulib used by ls(1),
df(1) and du(1) less aggressive if the integral part has two digits.

For example, a file slightly larger than 10T gets immediately rounded to 11T:

$ truncate --size 10T /var/tmp/test
$ ls -l -h /var/tmp/test
-rw-r--r--. 1 root root 10T Oct  8 11:22 /var/tmp/test
$ truncate --size +1 /var/tmp/test
$ ls -l -h /var/tmp/test
-rw-r--r--. 1 root root 11T Oct  8 11:22 /var/tmp/test

The users were made aware of numfmt(1) for custom formatting.  However, they
still expressed interest in changing the upstream default to always show one
digit of the fractional part also in the case of two-digit integral parts to
improve the precision.

I know that the current behaviour has been in use for a long time and changing
it may be potentially breaking.  Therefore, I'd like to hear the opinions of
other coreutils users first.

Right. Though there is still the same accuracy issue as you increase size.
You're only adding 1 power of 10, whereas numfmt as you've mentioned
gives full control.

Related to this is --block-size. For e.g.

  $ ls -lh  -rw-r--r--. 1 padraig padraig 2.2M Oct  7 15:41 Makefile  
-rw-r--r--. 1 padraig padraig 7.9K Sep 17 13:18 Makefile.am
  -rw-r--r--. 1 padraig padraig 2.5M Oct  7 15:41 Makefile.in
  drwxrwxr-x. 1 padraig padraig 3.0K Oct  7 16:00 man
  -rw-r--r--. 1 padraig padraig 257K Oct  7 16:00 NEWS

  $ ls -lh --block-size=T
  -rw-r--r--. 1 padraig padraig 1T Oct  7 15:41 Makefile
  -rw-r--r--. 1 padraig padraig 1T Sep 17 13:18 Makefile.am
  -rw-r--r--. 1 padraig padraig 1T Oct  7 15:41 Makefile.in
  drwxrwxr-x. 1 padraig padraig 1T Oct  7 16:00 man
  -rw-r--r--. 1 padraig padraig 1T Oct  7 16:00 NEWS

If we wanted to move configuration within each tool,
then I suppose you extend --human-readable to take a width option,
to change from the default of 4, but I'm not sure that's needed,
especially given we have numfmt available.

cheers,
Padraig

Reply via email to