From owner-freebsd-hackers@FreeBSD.ORG Sat Jun 19 22:54:40 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 6AD4216A4CE for ; Sat, 19 Jun 2004 22:54:40 +0000 (GMT) Received: from mta10-svc.ntlworld.com (mta10-svc.ntlworld.com [62.253.162.94]) by mx1.FreeBSD.org (Postfix) with ESMTP id D9E1143D2D for ; Sat, 19 Jun 2004 22:54:39 +0000 (GMT) (envelope-from scott@fishballoon.org) Received: from llama.fishballoon.org ([81.104.195.124]) by mta10-svc.ntlworld.comESMTP <20040619225129.EGWE24992.mta10-svc.ntlworld.com@llama.fishballoon.org>; Sat, 19 Jun 2004 23:51:29 +0100 Received: from tuatara.fishballoon.org ([192.168.1.6]) by llama.fishballoon.org with esmtp (Exim 4.34 (FreeBSD)) id 1BbohK-000LnB-BP; Sat, 19 Jun 2004 23:52:30 +0100 Received: (from scott@localhost) by tuatara.fishballoon.org (8.12.11/8.12.11/Submit) id i5JMqTDM028959; Sat, 19 Jun 2004 23:52:29 +0100 (BST) (envelope-from scott) Date: Sat, 19 Jun 2004 23:52:29 +0100 From: Scott Mitchell To: Dimitry Andric Message-ID: <20040619225229.GE462@tuatara.fishballoon.org> References: <20040619175007.GB462@tuatara.fishballoon.org> <414787887.20040619210137@andric.com> <20040619193545.GC462@tuatara.fishballoon.org> <14210101.20040619220601@andric.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <14210101.20040619220601@andric.com> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 4.10-PRERELEASE i386 cc: freebsd-hackers@freebsd.org 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: Sat, 19 Jun 2004 22:54:40 -0000 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. > Note also that the fts(3) functions use qsort(3), which isn't stable, > so you will not always get the order in which these entries are listed > in the directory itself. Indeed. The proposed change will always give you a predictable ordering for a given set of entries. Scott -- =========================================================================== Scott Mitchell | PGP Key ID | "Eagles may soar, but weasels Cambridge, England | 0x54B171B9 | don't get sucked into jet engines" scott at fishballoon.org | 0xAA775B8B | -- Anon