Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Mar 2008 01:17:08 -0400
From:      Mike Meyer <mwm-keyword-freebsdhackers2.e313df@mired.org>
To:        <freebsd-hackers@freebsd.org>
Subject:   Problem with find -prune...
Message-ID:  <20080324011708.107ec3cb@bhuda.mired.org>

next in thread | raw e-mail | index | archive | help
find -prune seems to not quite do what it says. At least, when delete
is used. Here's an example tree (on 7.0-RELEASE, amd64 build):

bhuda# ls -Rl /tmp/x
total 2
drwx------  2 root  wheel  512 Mar 24 01:01 y

/tmp/x/y:
total 2
-rw-r--r--  1 root  wheel  1111 Mar 24 01:01 motd

/tmp/x contains a subdirectory closed to everyone but root, which has
a file in it. No problem. Point find at it as a user:


bhuda% find /tmp/x -print
/tmp/x
/tmp/x/y
find: /tmp/x/y: Permission denied

As expected, it complains. Now let's use prune to trim the search - at
the root of the tree:

bhuda% find /tmp/x -prune
/tmp/x

Hmm, it prints the root of the tree. That might be a bug; might
not. But we can fix it with a little tweak:

bhuda% find /tmp/x -prune -o -print
bhuda% 

Making the print conditional on not pruning, and we always prune. Ok,
now let's look at what looks to me like a bug:

bhuda% find /tmp/x -prune -o -delete
find: /tmp/x/y: Permission denied

Why on earth (or off it) is find trying to look at /tmp/x? Am I
correct in assuming that this is a bug?

	Thanks,
	<mike
-- 
Mike Meyer <mwm@mired.org>		http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080324011708.107ec3cb>