GNU bug report logs -
#71803
ls --time=mtime is sorting by name instead of mtime
Previous Next
Reported by: Dave <dmisc2 <at> gmail.com>
Date: Thu, 27 Jun 2024 15:21:02 UTC
Severity: normal
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 71803 in the body.
You can then email your comments to 71803 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#71803
; Package
coreutils
.
(Thu, 27 Jun 2024 15:21:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Dave <dmisc2 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Thu, 27 Jun 2024 15:21:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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
Reply sent
to
Pádraig Brady <P <at> draigBrady.com>
:
You have taken responsibility.
(Thu, 27 Jun 2024 17:53:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Dave <dmisc2 <at> gmail.com>
:
bug acknowledged by developer.
(Thu, 27 Jun 2024 17:53:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 71803-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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
[ls--time=mtime-sort.diff (text/x-patch, attachment)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 26 Jul 2024 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 324 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.