emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#71803: closed (ls --time=mtime is sorting by name instead of mtime)


From: GNU bug Tracking System
Subject: bug#71803: closed (ls --time=mtime is sorting by name instead of mtime)
Date: Thu, 27 Jun 2024 17:53:01 +0000

Your message dated Thu, 27 Jun 2024 18:51:13 +0100
with message-id <98ba27e7-863f-4f65-96b4-7a2cf6e825dc@draigBrady.com>
and subject line Re: bug#71803: ls --time=mtime is sorting by name instead of 
mtime
has caused the debbugs.gnu.org bug report #71803,
regarding ls --time=mtime is sorting by name instead of mtime
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
71803: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71803
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: ls --time=mtime is sorting by name instead of mtime Date: Thu, 27 Jun 2024 11:05:51 -0400
The ls command without the -l option and with the --time=mtime option,
is incorrectly sorting by the name rather than by the modification
time.

ls               # sorts by name (ok)
ls --time=mtime  # sorts by name (should sort by mtime)
ls --time=ctime  # sorts by ctime (ok)
ls --time=atime  # sorts by atime (ok)
ls --time=birth  # sorts by birth (ok)

ls -c               # sorts by ctime (ok)
ls -c --time=mtime  # sorts by name (should sort by mtime)
ls -c --time=ctime  # sorts by ctime (ok)
ls -c --time=atime  # sorts by atime (ok)
ls -c --time=birth  # sorts by birth (ok)

ls -u               # sorts by atime (ok)
ls -u --time=mtime  # sorts by name (should sort by mtime)
ls -u --time=ctime  # sorts by ctime (ok)
ls -u --time=atime  # sorts by atime (ok)
ls -u --time=birth  # sorts by birth (ok)

// The current statement in ls.c (lines 2383-2387)
  sort_type = (0 <= sort_opt ? sort_opt
               : (format != long_format
                  && (time_type == time_ctime || time_type == time_atime
                      || time_type == time_btime))
               ? sort_time : sort_name);

// Proposed correction (untested)
  sort_type = (0 <= sort_opt ? sort_opt
               : (format != long_format
                  && (time_type == time_ctime || time_type == time_atime
                      || time_type == time_btime || time_type == time_mtime))
               ? sort_time : sort_name);

ls (GNU coreutils) 9.4

Linux 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20
00:40:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux



--- End Message ---
--- Begin Message --- Subject: Re: bug#71803: ls --time=mtime is sorting by name instead of mtime Date: Thu, 27 Jun 2024 18:51:13 +0100 User-agent: Mozilla Thunderbird Beta
On 27/06/2024 16:05, Dave wrote:
The ls command without the -l option and with the --time=mtime option,
is incorrectly sorting by the name rather than by the modification
time.

ls               # sorts by name (ok)
ls --time=mtime  # sorts by name (should sort by mtime)

// The current statement in ls.c (lines 2383-2387)
   sort_type = (0 <= sort_opt ? sort_opt
                : (format != long_format
                   && (time_type == time_ctime || time_type == time_atime
                       || time_type == time_btime))
                ? sort_time : sort_name);

// Proposed correction (untested)
   sort_type = (0 <= sort_opt ? sort_opt
                : (format != long_format
                   && (time_type == time_ctime || time_type == time_atime
                       || time_type == time_btime || time_type == time_mtime))
                ? sort_time : sort_name);

Right, we should be applying this GNU extension to --time=mtime also.
I.e. sorting when not displaying time (-l not specified),
and no other sorting specific option is used.

The proposed fix wouldn't work as time_mtime is the default,
so we'd be sorting by mtime rather than name by default.

I'll apply the attached later to address this.

Marking this as done.

thanks,
Pádraig

Attachment: ls--time=mtime-sort.diff
Description: Text Data


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]