bug#26741: Numeric sort in ls

2017-05-02 Thread Tony Malykh
It should be possible from technical point of view to add a new option
--numeric-sort or --natural-sort that wouldn't conflict with -X or any
other sort options of ls.

I am a C++ developer myself, so I can implement this new options
myself. Would the community of coreutils developers be interested in
accepting a patch like this?

I've looked at the source code, and it seems that the function that
does lexicographic sorting is strcoll. The implementation of this
function is quite complicated, and it is implemented in glibc. What I
would propose is to write a new function strcoll_natural in ls code,
that would identify which characters are digits in the input strings.
Then it would pass non-digit chunks to strcoll to preserve the
handling of locales, and it would do the smart comparison of digits as
numbers.

As a separate note, what I dislike about ls -v option is that it
handles capital letters in a different way than without the -v option:
$ ls -1
a
B
c
D

$ ls -1v
B
D
a
c

I have no particular preference among these two, but I'd rather see
them consistent. It seems like this is a known "caveat" of -v option,
since it ignores the locale.

Tony


On 5/2/17, Andreas Schwab  wrote:
> On Mai 01 2017, Tony Malykh  wrote:
>
>> It appears that version sort (-v) option achieves exactly that.
>> However, the problem with it is that it seems to be incompatible with
>> extension sort (-X) option.
>
> This isn't limited to these two option.  Generally, ls only supports a
> single sort option, with later options overriding previous ones.
>
> Andreas.
>
> --
> Andreas Schwab, sch...@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
>





bug#26741: Numeric sort in ls

2017-05-02 Thread Andreas Schwab
On Mai 01 2017, Tony Malykh  wrote:

> It appears that version sort (-v) option achieves exactly that.
> However, the problem with it is that it seems to be incompatible with
> extension sort (-X) option.

This isn't limited to these two option.  Generally, ls only supports a
single sort option, with later options overriding previous ones.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





bug#26727: Plain ls (from coreutils git master local build) sometimes emit leading spaces at output lines

2017-05-02 Thread Paul Eggert

On 05/01/2017 09:12 AM, Pádraig Brady wrote:

That was done to better align items when 'quotes' are added on some items.


Couldn't 'ls' add these spaces only in columns that contain both quoted 
and unquoted names, and not bother with the spaces in other columns? 
That would be a more-efficient use of valuable screen real estate.







bug#26727: Plain ls (from coreutils git master local build) sometimes emit leading spaces at output lines

2017-05-02 Thread Shlomi Fish
On Mon, 1 May 2017 09:12:40 -0700
Pádraig Brady  wrote:

> tag 26727 notabug
> close 26727
> stop
> 
> On 01/05/17 02:17, Shlomi Fish wrote:
> > On Mageia x86-64 6 and fedora 26 x86-64, I am getting this with an ls
> > inovcation with ls from coreutils git master commit
> > d91e912343ab04b37d011b5c8a7c0723edc35e3d :
> > 
> > shlomif@telaviv1:~$ /home/shlomif/apps/to-del-coreutils/bin/ls
> >  apps   Backup   conf  Docs   Mailnode_modules   tmp
> >  Arcs   bin  Desktop   Download   Music   progs 'VirtualBox VMs'
> > shlomif@telaviv1:~$ ls # mageia v6's
> > apps  Backup  conf Docs  Mail   node_modules  tmp
> > Arcs  bin Desktop  Download  Music  progs 'VirtualBox VMs'
> > shlomif@telaviv1:~$
> > 
> > 
> > As you can see, in the git master output there are leading spaces in the
> > output lines. Can and should this be fixed?  
> 
> That was done to better align items when 'quotes' are added on some items.
> It's a trade off and your example is pretty much worst case.
> If you prefer you can get original output by adding -N to your ls alias.
> 

Thanks for the insight!

> thanks,
> Pádraig



-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://youtu.be/xZLwtc9x4yA - Anime in Real Life!! (Parody)

Bachelors know more about women than married men. If they didn't, they'd be
married, too.
— http://en.wikiquote.org/wiki/H._L._Mencken

Please reply to list if it's a mailing list post - http://shlom.in/reply .