From owner-freebsd-current@FreeBSD.ORG Mon Nov 21 12:39:07 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6E21516A420 for ; Mon, 21 Nov 2005 12:39:07 +0000 (GMT) (envelope-from b.candler@pobox.com) Received: from thorn.pobox.com (thorn.pobox.com [208.210.124.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id BD3B043D95 for ; Mon, 21 Nov 2005 12:38:55 +0000 (GMT) (envelope-from b.candler@pobox.com) Received: from thorn (localhost [127.0.0.1]) by thorn.pobox.com (Postfix) with ESMTP id A57EEAB; Mon, 21 Nov 2005 07:39:16 -0500 (EST) Received: from mappit.local.linnet.org (212-74-113-67.static.dsl.as9105.com [212.74.113.67]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by thorn.sasl.smtp.pobox.com (Postfix) with ESMTP id 61AF245E; Mon, 21 Nov 2005 07:39:14 -0500 (EST) Received: from lists by mappit.local.linnet.org with local (Exim 4.54 (FreeBSD)) id 1EeAwd-0005px-4u; Mon, 21 Nov 2005 12:38:51 +0000 Date: Mon, 21 Nov 2005 12:38:51 +0000 From: Brian Candler To: Peter Jeremy Message-ID: <20051121123851.GA22368@uk.tiscali.com> References: <20051116161540.GB4383@uk.tiscali.com> <437F7E22.5050800@freebsd.org> <20051120192914.GC19572@uk.tiscali.com> <20051121064459.GB1395@cirb503493.alcatel.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051121064459.GB1395@cirb503493.alcatel.com.au> User-Agent: Mutt/1.4.2.1i Cc: freebsd-current@freebsd.org, Garance A Drosihn Subject: Re: Order of files with 'cp' X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Nov 2005 12:39:07 -0000 On Mon, Nov 21, 2005 at 05:44:59PM +1100, Peter Jeremy wrote: > Alternatively, make two passes through argv - on the first pass, copy > all the directories, on the second pass, copy all the files. Or vice versa :-) The comment says it copies files before directories. However the implementation of mastercmp() returns -1 when comparing directory A to anything else B; therefore it sorts directories before files. So at very least the comment needs changing. I agree that a real-world test is the only way to settle the best behaviour definitively. Also, remember that cp -R can work recursively to any depth. Handling argv[] in two passes as you suggest only affects the first level. Now, perhaps when copying subdirectories we care even less about preserving the 'natural' order of files; but as has been pointed out elsewhere, it's quite likely that we could have 10,000 files and not really want to go to the trouble of sorting them, just to select the subsets of 'all directories' and 'all non-directories'. In this case, implementing the two-pass selection as an option within fts_open makes sense. Regards, Brian.