From owner-freebsd-current@FreeBSD.ORG Mon May 17 03:37:07 2004 Return-Path: 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 9930A16A4CE; Mon, 17 May 2004 03:37:07 -0700 (PDT) Received: from fillmore.dyndns.org (port-212-202-49-130.reverse.qsc.de [212.202.49.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id 73EFC43D5C; Mon, 17 May 2004 03:37:06 -0700 (PDT) (envelope-from eikemeier@fillmore-labs.com) Received: from [172.16.0.2] (helo=fillmore-labs.com) by fillmore.dyndns.org with esmtp (Exim 4.34; FreeBSD) id 1BPfUU-0000xP-Hj; Mon, 17 May 2004 12:37:05 +0200 Message-ID: <40A895CE.9050505@fillmore-labs.com> Date: Mon, 17 May 2004 12:37:02 +0200 From: Oliver Eikemeier Organization: Fillmore Labs GmbH - http://www.fillmore-labs.com/ MIME-Version: 1.0 To: FreeBSD current Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit User-Agent: KMail/1.5.9 cc: Ruslan Ermilov Subject: RFC: new primary -depth n/-level n for find(1) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 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, 17 May 2004 10:37:07 -0000 find(1) should have a primary that is true iff the current file is n levels deep in the tree. This patch implements `-depth n' and an alias `-level n' which support the usual +/- modifiers, with `-depth +-1' essentially being a noop. The reason for implementing both was a discussion with ruslan, where he preferred `-depth [[+|-]level]', while I did not like the dual syntax that depth would have, because of its definition in IEEE 1003.1. Basically this allow one to do find /usr/ports -maxdepth 2 -name Tools -prune -o -level 2 -type d -print or find /usr/ports -maxdepth 2 -name Tools -prune -o -depth 2 -type d -print which currently can only be done with something like find /usr/ports -mindepth 2 -maxdepth 2 -regex '.*/Tools/[^/]*' -prune -o -type d -print which lists all port directories without Tools (this example lists some additional files, like packages, distfiles and CVS). I'm happy with the dual syntax, and probably I should change the manpage to state that `-depth' is equivalent to `-d' and `-depth n' equivalent to `-level n' if we go with this solution, but I'm also comfortable with having only one of `-level n' or `-depth n', I just wanted to have the functionality available. Any opinions? While I'm here, fix -maxdepth when depth-first traversal is done, try: find -d /usr -maxdepth 2 Which also doesn't give you warnings if any files on level three you don't really care for are unreadable. The patches for -CURRENT and -STABLE are at: http://people.freebsd.org/~eik/patches/find-depth.5.patch MD5 (find-depth.5.patch) = 5e52ac3c090726c609a9b582f6fbc993 http://people.freebsd.org/~eik/patches/find-depth.4.patch MD5 (find-depth.4.patch) = 6b67d3ac20c8fb5857d2d54f0365b518 -Oliver