From owner-freebsd-arch Thu Dec 14 6:20:14 2000 From owner-freebsd-arch@FreeBSD.ORG Thu Dec 14 06:20:10 2000 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from ringworld.nanolink.com (ringworld.nanolink.com [195.24.48.189]) by hub.freebsd.org (Postfix) with SMTP id 53FE137B400 for ; Thu, 14 Dec 2000 06:20:08 -0800 (PST) Received: (qmail 2495 invoked by uid 1000); 14 Dec 2000 14:19:07 -0000 Date: Thu, 14 Dec 2000 16:19:07 +0200 From: Peter Pentchev To: Sheldon Hearn Cc: arch@freebsd.org Subject: Re: add -I ignoremask option to du(1) Message-ID: <20001214161907.D369@ringworld.oblivion.bg> Mail-Followup-To: Sheldon Hearn , arch@freebsd.org References: <20001214034803.C575@ringworld.oblivion.bg> <55313.976800156@axl.fw.uunet.co.za> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <55313.976800156@axl.fw.uunet.co.za>; from sheldonh@uunet.co.za on Thu, Dec 14, 2000 at 03:22:36PM +0200 Sender: roam@ringworld.nanolink.com Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, Dec 14, 2000 at 03:22:36PM +0200, Sheldon Hearn wrote: > > > On Thu, 14 Dec 2000 03:48:04 +0200, Peter Pentchev wrote: > > > Is there a reason no one has done this yet? :) > > I think we're getting totally out of hand with respect to teaching > utilities how to do each others' jobs for one another. I'm aware that danger lieth along that path. However, see below. > Recursion, exclusion and pattern matching are all creeping into > utilities that once did one job well. These things are all handled very > well by find and the shell. In general, I agree. However, consider the problem at hand: getting information about the filesystem usage of files and directories down a tree, excluding certain files. Let's consider an example when all files and directories matching either of '*.c' and 'CVS' patterns need to be excluded. I mentioned in my first email that this could be done through some find(1) hackery. I can see several possible problems there - feel free to correct my admittedly not-thoroughly-informed opinions on any of those. 1. Non-obvious syntax. OK, I'll admit that this was the main reason - I was almost stumped when I had to find out how to do it :) And I am still somewhat doubtful as to whether I have really found a way. The best I've come up with so far is: find path ( ( -name *.c -or -name CVS ) -and -prune ) -or -print or -ls instead of -print. With -print, du(1) descends directories, showing space allocated to ignored files, too. With -ls, I can easily awk out the filesize and name, but I'd have to do additional scripting to keep track of directory tree totals. 2. With find(1) and du(1) combined, there might be a heavy duplication of effort involved - traversing a directory tree twice. This does not happen with find -ls | awk, but see above for the directory tree totals :( 3. I'd think the fts routines that du(1) uses could be more efficient than having find(1) pass its output through (possibly blocking) pipes to whatever happens to be on the other end. Note that this is a *highly* uninformed opinion though, and I should probably not be mentioning it at all :) > So the only question is whether we shrug and continue down this road, or > limit ourselves to only those silly enhancements that we deem necessary > for compatibility with other platforms. As I mentioned above, I agree in principle; just not in this particular case. This might very well turn into creeping featurism (which I know will not be allowed :), but I like telling myself that it's not all that bad :) G'luck, Peter -- I am the thought you are now thinking. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message