coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: numfmt (=print 'human' sizes) updates


From: Assaf Gordon
Subject: Re: numfmt (=print 'human' sizes) updates
Date: Fri, 21 Dec 2012 19:51:09 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4

Hello Pádraig,

Thanks for the review and the feedback.

Pádraig Brady wrote, On 12/21/2012 12:42 PM:
> 
> It's looking like a really useful cohesive command.
> 

The attached patch addresses the following issues:

1. changed the "---devdebug" option
2. incorporated most of 'indent -nut' recommendations. 
3. improved the usage string, to generate somewhat better man page.
  (help2man is a bit finicky about formatting, so it's not optimal). 

4. "i" suffix with "iec" input/output:

I understand the reason for always adding "i", as it is The Right Thing to do.
But I think some (most?) people still treat single-letter suffix (K/M/G/T/etc.) 
as a valid suffix for both SI and IEC, and deduce the scale from the context of 
whatever they're working on. Forcing them to use "Ki" might be too obtrusive.
It could also mess-up automated scripted, when IEC scale is needed, but only 
with single-letter suffix (and there are many programs like that).

As a compromise, I've added yet another scale option: "ieci" .
When used with "--from=ieci", a two-letter suffix is required.
When used with "--to=ieci", "i" will always be appended.

Examples:
====
$ ./src/numfmt --to=iec 4096
4.0K
$ ./src/numfmt --to=ieci 4096
4.0Ki
$ ./src/numfmt --from=iec 4K
4096
$ ./src/numfmt --from=ieci 4Ki
4096
$ ./src/numfmt --from=auto 4Ki
4096
$ ./src/numfmt --from=auto 4K
4000

# 'ieci' requires the 'i':
$ ./src/numfmt --from=ieci 4K 
./src/numfmt: missing 'i' suffix in input: '4K' (e.g Ki/Mi/Gi)

# 'iec' does not accept 'i':
$ ./src/numfmt --from=iec 4Ki
./src/numfmt: invalid suffix in input '4Ki': 'i'
====

I hope this cover all the options, while maintaining consistent and expected 
behavior.
(Optionally, we can change "iec" to behave like "ieci", and rename "ieci" to 
something else).


I will send "--format" and error message updates soon.

Regards,
 -gordon

Attachment: numfmt.9.patch.xz
Description: application/xz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]