Open sdgn opened 4 years ago
true; however, replacing strcmp
with strcoll
would lead to inconsistencies: --version-sort
is implemented with strverscmp
, and there is no strverscoll
function available. So feh
would sort images as "f1 f2 F3 F4", whereas feh --version--sort
would result in "F3 F4 f1 f2".
The same applies to ls: "ls -v" does not follow the locale's sort order
Do you think locale-aware sorting by default outweighs the introduced inconsistency between feh invocations with and without --version-sort
?
I think --version-sort
using strverscmp
is totally fine, as it behaves like ls -v
and sort -V
do, today.[1]
I would only change the default case, so that strcmp_or_strverscmp
becomes strcoll_or_strverscmp
.
So yes, sorting "f1 f2 F3 F4" with vs. without --version-sort
would yield different results, just like in the core utilities.
Should strverscmp
become locale-aware at some point, feh will also benefit from that change. And if Coreutils switches to a new locale-aware version sort (which seems very unlikely), feh can – or should – switch, too.
1: The only difference is that ls and sort use Gnulib's filevercmp
, which stems from Debian's dpkg and is supposed to handle file suffixes better than strverscmp
.
feh compares file and directory names using
strcmp
(as opposed tostrcoll
). This can lead to inconsistent sorting whenLC_COLLATE
is not set to "C" or "POSIX".