Thanks to everyone who replied with all the great feedback and input.
Here's an update on what I've done with this feature.

1. I tried various options to find a solid way of getting number
formatting details (e.g. the thousands separator, and the grouping data)
from the locale data, but this seems to me to still be murky territory,
in the sense that the locale data is often incomplete, and the code has
to account for a lot of exceptions.  So what I did for now is make the
ls option accept an optional argument, allowing the user the explicitly
specify the thousands separator.  If not specified, it defaults to a
comma.  The code also currently groups by three digits only.

2. I changed the option to "--thousands-sep[=CHAR]" instead of
"--kilo-separator" and "-K".  Allowing short options (-K) to take
optional arguments causes all sorts of confusion and inconsistency, so
I just made it a long option only.  Plus I think "--thousands-sep" has
a better ring to it than "--kilo-separator".

3. I added code to make the "total" line at the top of ls output
also print out with a thousands separator.

Here is new sample output.  The first uses the default thousands
separator.  The second uses the optional arg to set it to '.', and
the third is normal "ls -l" output for comparison.

$
$ ls -l --thousands-sep
total 1,213,124
-rw-rw-r--    1 user1    user1      104,857,600 Dec 28 14:43 file1
-rw-rw-r--    1 user1    user1              124 Dec 28 14:44 file2
-rw-rw-r--    1 user1    user1           14,336 Dec 28 14:45 file3
-rw-rw-r--    1 user1    user1    1,101,004,800 Dec 28 14:49 file4
-rw-rw-r--    1 user1    user1       35,127,296 Dec 28 14:54 file5
$ 
$ ls -l --thousands-sep=.
total 1.213.124
-rw-rw-r--    1 user1    user1      104.857.600 Dec 28 14:43 file1
-rw-rw-r--    1 user1    user1              124 Dec 28 14:44 file2
-rw-rw-r--    1 user1    user1           14.336 Dec 28 14:45 file3
-rw-rw-r--    1 user1    user1    1.101.004.800 Dec 28 14:49 file4
-rw-rw-r--    1 user1    user1       35.127.296 Dec 28 14:54 file5
$ 
$ ls -l
total 1213124
-rw-rw-r--    1 user1    user1    104857600 Dec 28 14:43 file1
-rw-rw-r--    1 user1    user1         124 Dec 28 14:44 file2
-rw-rw-r--    1 user1    user1       14336 Dec 28 14:45 file3
-rw-rw-r--    1 user1    user1    1101004800 Dec 28 14:49 file4
-rw-rw-r--    1 user1    user1    35127296 Dec 28 14:54 file5
$ 

At this point I think I am ready to officially propose that this option
be accepted into the fileutils package.

John Saalwaechter

Reply via email to