[TUHS] Command line options and complexity

Greg 'groggy' Lehey grog at lemis.com
Fri Mar 13 10:36:47 AEST 2020

On Thursday, 12 March 2020 at 16:22:01 +1100, Dave Horsfall wrote:
> On Thu, 12 Mar 2020, Greg 'groggy' Lehey wrote:
>> A good example.  But you're not removing options, you're just redefining
>> them.  In fact I find the -h option particularly emetic, so a better
>> choice in removing options would be to remove -h and use a filter to
>> mutilate the sizes:
>>  $ ls -l | humanize
> I also had something like that in mind, except being British/Australian
> I'd spell it with an "s" :-)

It's a common misconception that -ize is US English.  The Oxford
English Dictionary, normally not prescriptive, prefers it.  See
https://www.oed.com/page/faqs/Frequently+asked+questions#spell.  I
personally had -ise drummed out of me by my uncle, very much

>> And then there's the question why you don't like the standard output.
>> Because the number strings are too long and difficult to read, maybe?
>> That's the rationale for the -, option.
> More than likely; as I approach age 68 I notice that I'm losing some
> cognitive facility...  I might start using "," and see if I like it, but I
> see that the Mac doesn't have it (my Penguin is off the air at the
> moment), and having it as an environment variable would be nice.

Yes, currently only FreeBSD has it.  But you have the sources.  Apart
from option handling, it's only:

--- print.c     (.../head/bin/ls/print.c)       (revision 241014)
+++ print.c     (.../stable/10/bin/ls/print.c)  (working copy)
@@ -606,6 +606,10 @@
                humanize_number(buf, sizeof(buf), (int64_t)bytes, "",
                    HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
                (void)printf("%*s ", (u_int)width, buf);
+       } else if (f_thousands) {               /* with commas */
+               /* This format assignment needed to work round gcc bug. */
+               const char *format = "%*j'd ";
+               (void)printf(format, (u_int)width, bytes);
        } else
                (void)printf("%*jd ", (u_int)width, bytes);

A quick and dirty fix would be simply to replace the format string.

Sent from my desktop computer.
Finger grog at lemis.com for PGP public key.
See complete headers for address and phone numbers.
This message is digitally signed.  If your Microsoft mail program
reports problems, please read http://lemis.com/broken-MUA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20200313/0e14eafa/attachment.sig>

More information about the TUHS mailing list