From owner-freebsd-hackers@FreeBSD.ORG Mon Jun 21 05:44:34 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 622FD16A4CE for ; Mon, 21 Jun 2004 05:44:34 +0000 (GMT) Received: from VARK.homeunix.com (c-67-174-240-84.client.comcast.net [67.174.240.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id D636943D39 for ; Mon, 21 Jun 2004 05:44:33 +0000 (GMT) (envelope-from das@FreeBSD.ORG) Received: from VARK.homeunix.com (localhost [127.0.0.1]) by VARK.homeunix.com (8.12.11/8.12.10) with ESMTP id i5L5i6YR000982; Sun, 20 Jun 2004 22:44:07 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by VARK.homeunix.com (8.12.11/8.12.10/Submit) id i5L5i6co000981; Sun, 20 Jun 2004 22:44:06 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Date: Sun, 20 Jun 2004 22:44:06 -0700 From: David Schultz To: Scott Mitchell Message-ID: <20040621054406.GA927@VARK.homeunix.com> Mail-Followup-To: Scott Mitchell , David Malone , freebsd-hackers@FreeBSD.ORG, Dimitry Andric References: <20040619175007.GB462@tuatara.fishballoon.org> <414787887.20040619210137@andric.com> <20040619193545.GC462@tuatara.fishballoon.org> <14210101.20040619220601@andric.com> <20040619225229.GE462@tuatara.fishballoon.org> <20040620085912.GA7301@walton.maths.tcd.ie> <20040620144654.GG462@tuatara.fishballoon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040620144654.GG462@tuatara.fishballoon.org> cc: David Malone cc: freebsd-hackers@FreeBSD.ORG cc: Dimitry Andric Subject: Re: /bin/ls sorting bug? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jun 2004 05:44:34 -0000 On Sun, Jun 20, 2004, Scott Mitchell wrote: > On Sun, Jun 20, 2004 at 09:59:12AM +0100, David Malone wrote: > > On Sat, Jun 19, 2004 at 11:52:29PM +0100, Scott Mitchell wrote: > > > On Sat, Jun 19, 2004 at 10:06:01PM +0200, Dimitry Andric wrote: > > > > Looking through ls source shows that the sorting is done by passing a > > > > comparison function to fts_open(3). In the case of sorting by > > > > modification time, the *only* comparison made is of the mtime fields: > > > > > > You did see the patch attached to my original post, right? It modifies all > > > of these comparison functions to sort the two items by name (or reverse > > > name) in the case that their timestamps are equal. > > > > Hi Scott, > > > > Could you produce a version of your patch that uses the nanoseconds > > field too? I produced the one below, but I think the style in your > > patch was nicer. Also, I wonder if the revblahcmp functions should > > just call blahcmp with their arguments reversed? > > > > David. > > David, > > New patch attached that compares against the nanos field as well. It could > stand a bit of cleaning up to remove the overly long lines. > > I'm not sure I'd want this in the tree unless we also had an option to > display the nanoseconds - as it stands you could get items apparently > ordered wrongly, unless you knew the value of their nanos fields. I could > do that if people thought it would be useful. Sorting on nanoseconds too is likely to be more confusing than useful. Even if we use one of the precious few option letters ls doesn't use already to add a nanosecond display, most people won't know about it because they don't care about nanoseconds. They might care when they notice---as you did---that the sort order isn't what they expected. Is the point of sorting on nanoseconds to totally order the files based on modification time?