GNU bug report logs - #7176
Feature request: add option to display full units in -h and --si output

Previous Next

Package: coreutils;

Reported by: Mihai Capotă <mihai <at> mihaic.ro>

Date: Fri, 8 Oct 2010 16:58:02 UTC

Severity: normal

Tags: patch, wontfix

Merged with 14113

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7176 in the body.
You can then email your comments to 7176 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#7176; Package coreutils. (Fri, 08 Oct 2010 16:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mihai Capotă <mihai <at> mihaic.ro>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Fri, 08 Oct 2010 16:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mihai Capotă <mihai <at> mihaic.ro>
To: bug-coreutils <bug-coreutils <at> gnu.org>
Subject: Feature request: add option to display full units in -h and --si
	output
Date: Fri, 8 Oct 2010 18:52:26 +0200
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.

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"

Regards,
Mihai Capotă

[1] http://www.gnu.org/software/coreutils/manual/html_node/Block-size.html
[2] http://lists.gnu.org/archive/html/bug-coreutils/2007-02/msg00312.html




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#7176; Package coreutils. (Fri, 08 Oct 2010 22:44:01 GMT) Full text and rfc822 format available.

Message #8 received at 7176 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Mihai Capotă <mihai <at> mihaic.ro>
Cc: 7176 <at> debbugs.gnu.org
Subject: Re: bug#7176: Feature request: add option to display full units in
	-h	and --si output
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.




Information forwarded to bug-coreutils <at> gnu.org:
bug#7176; Package coreutils. (Mon, 01 Apr 2013 12:42:02 GMT) Full text and rfc822 format available.

Message #11 received at 7176 <at> debbugs.gnu.org (full text, mbox):

From: Mihai Capotă <mihai <at> mihaic.ro>
To: P <at> draigbrady.com
Cc: 7176 <at> debbugs.gnu.org, bug-gnulib <at> gnu.org, bug-coreutils <at> gnu.org
Subject: [PATCH] human: add unambiguous block_size_args
Date: Mon,  1 Apr 2013 14:38:25 +0200
The units used in the outputs of "human-readable" and "si" look
identical when "K/k" is not present. Add two block_size_args, "binary"
and "decimal", that disambiguate between the outputs of "human-readable"
and "si" by adding human_B to the list of options.

See bug 7176 in GNU coreutils,
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7176>.
---
 lib/human.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/human.c b/lib/human.c
index 613dc65..66a1835 100644
--- a/lib/human.c
+++ b/lib/human.c
@@ -394,11 +394,21 @@ human_readable (uintmax_t n, char *buf, int opts,
 # define DEFAULT_BLOCK_SIZE 1024
 #endif
 
-static char const *const block_size_args[] = { "human-readable", "si", 0 };
+static char const *const block_size_args[] =
+  {
+    "human-readable",
+    "si",
+    "binary",
+    "decimal",
+    0
+  };
+
 static int const block_size_opts[] =
   {
     human_autoscale + human_SI + human_base_1024,
-    human_autoscale + human_SI
+    human_autoscale + human_SI,
+    human_autoscale + human_SI + human_base_1024 + human_B,
+    human_autoscale + human_SI + human_B
   };
 
 static uintmax_t
-- 
1.7.9.5





Information forwarded to bug-coreutils <at> gnu.org:
bug#7176; Package coreutils. (Sat, 13 Apr 2013 23:57:02 GMT) Full text and rfc822 format available.

Message #14 received at 7176 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Mihai Capotă <mihai <at> mihaic.ro>
Cc: 7176 <at> debbugs.gnu.org
Subject: Re: [PATCH] human: add unambiguous block_size_args
Date: Sun, 14 Apr 2013 00:52:03 +0100
forcemerge 14113 7176
stop

On 04/01/2013 01:38 PM, Mihai Capotă wrote:
> The units used in the outputs of "human-readable" and "si" look
> identical when "K/k" is not present. Add two block_size_args, "binary"
> and "decimal", that disambiguate between the outputs of "human-readable"
> and "si" by adding human_B to the list of options.
> 
> See bug 7176 in GNU coreutils,
> <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7176>.
> ---
>  lib/human.c |   14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/human.c b/lib/human.c
> index 613dc65..66a1835 100644
> --- a/lib/human.c
> +++ b/lib/human.c
> @@ -394,11 +394,21 @@ human_readable (uintmax_t n, char *buf, int opts,
>  # define DEFAULT_BLOCK_SIZE 1024
>  #endif
>  
> -static char const *const block_size_args[] = { "human-readable", "si", 0 };
> +static char const *const block_size_args[] =
> +  {
> +    "human-readable",
> +    "si",
> +    "binary",
> +    "decimal",
> +    0
> +  };
> +
>  static int const block_size_opts[] =
>    {
>      human_autoscale + human_SI + human_base_1024,
> -    human_autoscale + human_SI
> +    human_autoscale + human_SI,
> +    human_autoscale + human_SI + human_base_1024 + human_B,
> +    human_autoscale + human_SI + human_B
>    };

So I was 50:50 on making this change, and in the meantime numfmt(1) was released,
which gives full control over number formatting, albeit in a more verbose/explicit form.

thanks,
Pádraig





Forcibly Merged 7176 14113. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Sat, 13 Apr 2013 23:57:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#7176; Package coreutils. (Tue, 16 Apr 2013 17:18:01 GMT) Full text and rfc822 format available.

Message #19 received at 7176 <at> debbugs.gnu.org (full text, mbox):

From: Mihai Capotă <mihai <at> mihaic.ro>
To: Pádraig Brady <P <at> draigbrady.com>
Cc: 7176 <at> debbugs.gnu.org
Subject: Re: [PATCH] human: add unambiguous block_size_args
Date: Tue, 16 Apr 2013 19:12:54 +0200
On Sun, Apr 14, 2013 at 1:52 AM, Pádraig Brady <P <at> draigbrady.com> wrote:
> So I was 50:50 on making this change, and in the meantime numfmt(1) was released,
> which gives full control over number formatting, albeit in a more verbose/explicit form.

Let me see if I can convince you with a use case. If you set
"BLOCK_SIZE=binary" in your shell configuration file, you get the
output you want from all programs that use gnulib. That's not only
about verbosity, it's something that cannot be easily done with
numfmt.

Mihai




Information forwarded to bug-coreutils <at> gnu.org:
bug#7176; Package coreutils. (Tue, 09 Oct 2018 20:42:02 GMT) Full text and rfc822 format available.

Message #22 received at 7176 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Mihai Capotă <mihai <at> mihaic.ro>,
 Pádraig Brady <P <at> draigbrady.com>
Cc: 7176 <at> debbugs.gnu.org
Subject: Re: bug#7176: [PATCH] human: add unambiguous block_size_args
Date: Tue, 9 Oct 2018 14:41:32 -0600
tags 7176 wontfix
close 7176
stop

(Triaging old bugs)

Hello,

On 16/04/13 11:12 AM, Mihai Capotă wrote:
> On Sun, Apr 14, 2013 at 1:52 AM, Pádraig Brady <P <at> draigbrady.com> wrote:
>> So I was 50:50 on making this change, and in the meantime numfmt(1) was released,
>> which gives full control over number formatting, albeit in a more verbose/explicit form.
> 
> Let me see if I can convince you with a use case. If you set
> "BLOCK_SIZE=binary" in your shell configuration file, you get the
> output you want from all programs that use gnulib. That's not only
> about verbosity, it's something that cannot be easily done with
> numfmt.

Given that:
1. numfmt does some of the requested functionality
2. environment variables are frowned upon and not likely to be expanded
3. there has been no further comments in 5 and a half years

I'm opting to close this bug, and we can always re-open the bug if
needed. Discussion can continue by replying to this thread,

regards,
 - assaf




Added tag(s) wontfix. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 09 Oct 2018 20:42:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 7176 <at> debbugs.gnu.org and Mihai Capotă <mihai <at> mihaic.ro> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 09 Oct 2018 20:42:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#7176; Package coreutils. (Tue, 09 Oct 2018 22:24:01 GMT) Full text and rfc822 format available.

Message #29 received at 7176 <at> debbugs.gnu.org (full text, mbox):

From: Mihai Capotă <mihai <at> mihaic.ro>
To: assafgordon <at> gmail.com
Cc: 7176 <at> debbugs.gnu.org, Pádraig Brady <P <at> draigbrady.com>
Subject: Re: bug#7176: [PATCH] human: add unambiguous block_size_args
Date: Tue, 9 Oct 2018 15:23:09 -0700
On Tue, 9 Oct 2018 at 13:41, Assaf Gordon <assafgordon <at> gmail.com> wrote:
>
> 2. environment variables are frowned upon and not likely to be expanded

This patch can be used without environment variables, e.g., "ls -l
--block-size=binary".

> I'm opting to close this bug, and we can always re-open the bug if
> needed. Discussion can continue by replying to this thread,

I am still interested in disambiguating the output without calling numfmt.

Mihai




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 07 Nov 2018 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 171 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.