Subject: dd: report base 1024 for bytes per second

From: Chris Ely <[email-masked]>
Date: Sat, 18 Jan 2025 09:17:31 -0500

Hello,

human options would be better if it included base 1024 by default, the code
can turn that bit off where it doesn't want it (the si transfer status
value, should be the only place).

I think the minimal changes would be something like this:

https://github.com/coreutils/coreutils/compare/master...tcely:coreutils:patch-1.patch

>From fdf9763a069db4f0c80a84efae1232123f3d44a3 Mon Sep 17 00:00:00 2001
From: tcely
Date: Sat, 18 Jan 2025 08:00:46 -0500
Subject: [PATCH] Turn on human_base_1024 by default

There was only one place not using that bit.
Turn it off once rather than turning on multiple places.
---
 src/dd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/dd.c b/src/dd.c
index 4e914336b9..b0425e29c4 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -654,6 +654,7 @@ Options are:\n\
 /* Common options to use when displaying sizes and rates.  */

 enum { human_opts = (human_autoscale | human_round_to_nearest
+                     | human_base_1024 | human_group_digits
                      | human_space_before_unit | human_SI | human_B) };

 /* Ensure input buffer IBUF is allocated.  */
@@ -738,7 +739,7 @@ print_xfer_stats (xtime_t progress_time)
   char hbuf[3][LONGEST_HUMAN_READABLE + sizeof slash_s];
   double delta_s;
   char const *bytes_per_second;
-  char const *si = human_readable (w_bytes, hbuf[0], human_opts, 1, 1);
+  char const *si = human_readable (w_bytes, hbuf[0], human_opts & (~
human_base_1024), 1, 1);
   char const *iec = human_readable (w_bytes, hbuf[1],
                                     human_opts | human_base_1024, 1, 1);