Josh Triplett wrote: > Since upgrading to coreutils 7.1, ls -v no longer sorts correctly; > specifically, some dotfiles now appear at the end rather than with the > other dotfiles. I use LC_COLLATE=C, so this does not represent a locale > problem. > > The correct sorting, with coreutils 6.10-6: > > $ ls -a -v > .. .. .0 .9 .A .Z .a .z 0 9 A Z a z > > The incorrect sorting, With coreutils 7.1-2: > > $ ls -a -v > .. .A .Z .a .z 0 9 A Z a z .0 .9 .. > > Notice that .0, .9, and .. moved to the end.
Thanks for the report. That's been fixed in gnulib. Here's what's going into coreutils: >From c0dbba5fb795ee209e8513b6eaa756bc7d212bc0 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Sat, 7 Mar 2009 20:41:00 +0100 Subject: [PATCH] tests: ls -v: exercise the bug fixed by gnulib's new filevercmp * tests/misc/ls-misc (version-sort): New test. (mk_file): New function. Reported by Josh Triplett in <http://bugs.debian.org/517558>. Details in http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/16902 * NEWS (Bug fixes): Mention it. --- NEWS | 3 +++ THANKS | 1 + tests/misc/ls-misc | 25 +++++++++++++++++++++---- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 0f6e853..63c7e19 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,9 @@ GNU coreutils NEWS -*- outline -*- The bug strikes only with both --recursive (-r, -R) and --link (-l). [bug introduced in coreutils-7.1] + ls --sort=version (-v) sorted names beginning with "." inconsistently. + Now, names that start with "." are always listed before those that don't. + pr: fix the bug whereby --indent=N (-o) did not indent header lines [bug introduced in coreutils-6.9.90] diff --git a/THANKS b/THANKS index e40d2b0..46d077b 100644 --- a/THANKS +++ b/THANKS @@ -290,6 +290,7 @@ Jon Peatfield [email protected] Joost van Baal [email protected] Jorge Stolfi [email protected] Joseph S. Myers [email protected] +Josh Triplett [email protected] Joshua Hudson [email protected] Josselin Mouette [email protected] Juan F. Codagnone [email protected] diff --git a/tests/misc/ls-misc b/tests/misc/ls-misc index 5a93b51..b58949e 100755 --- a/tests/misc/ls-misc +++ b/tests/misc/ls-misc @@ -1,6 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 1998, 2000-2008 Free Software Foundation, Inc. +# Copyright (C) 1998, 2000-2009 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -64,12 +64,20 @@ sub setuid_setup() . "so can't run this test\n"), exit 77; } +sub mk_file(@) +{ + foreach my $f (@_) + { + open (F, '>', $f) && close F + or die "creating $f: $!\n"; + } +} + sub mkdir_d {mkdir 'd',0755 or die "d: $!\n"} sub rmdir_d {rmdir 'd' or die "d: $!\n"} my $mkdir = {PRE => sub {mkdir_d}}; my $rmdir = {POST => sub {rmdir_d}}; -my $mkdir_reg = {PRE => sub {mkdir_d; open (FH, '>d/f') && close FH - or die "d/f: $!\n" }}; +my $mkdir_reg = {PRE => sub {mkdir_d; mk_file 'd/f' }}; my $rmdir_reg = {POST => sub {unlink 'd/f' or die "d/f: $!\n"; rmdir 'd' or die "d: $!\n"}}; @@ -100,10 +108,12 @@ my $rmdir_d_slink = {POST => sub {unlink 'd/s' or die "d/s: $!\n"; sub make_j_d () { mkdir 'j', 0700 or die "creating j: $!\n"; - (open F, '>j/d') && close F or die "creating j/d: $!\n"; + mk_file 'j/d'; chmod 0555, 'j/d' or die "making j/d executable: $!\n"; } +my @v1 = qw(0 9 A Z a z); +my @v_files = ((map { ".$_" } @v1), @v1); my $exe_in_subdir = {PRE => sub { make_j_d (); push_ls_colors('ex=01;32') }}; my $remove_j = {POST => sub {unlink 'j/d' or die "j/d: $!\n"; rmdir 'j' or die "j: $!\n"; @@ -207,6 +217,13 @@ my @Tests = # For 5.97 and earlier, --file-type acted like --indicator-style=slash. ['file-type', '--file-type d', {OUT => "s...@\n"}, $mkdir_d_slink, $rmdir_d_slink], + + # 7.1 had a regression in how -v -a ordered some files + ['version-sort', '-v -A ' . join (' ', @v_files), + {OUT => join ("\n", @v_files) . "\n"}, + {PRE => sub { mk_file @v_files }}, + {POST => sub { unlink @v_files }}, + ], ); # Start with an unset LS_COLORS environment variable. -- 1.6.2.rc1.285.gc5f54 -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected]

