bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #46305] Doing "find -L . -type d -delete" fails on symlinks to dire


From: James Youngman
Subject: [bug #46305] Doing "find -L . -type d -delete" fails on symlinks to directories.
Date: Sun, 01 Nov 2015 21:23:19 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36

Update of bug #46305 (project findutils):

                  Status:                    None => Wont Fix               

    _______________________________________________________

Follow-up Comment #1:

> The '-L' option makes '-type d' detect symlinks to directories, but
'-delete' doesn't treat them as such. 

I don't think that's what is happening.  Use of -delete automatically turns on
-depth.  This means that the filesystem is visited in postorder.  For the
command line " find -L . -type d -delete" this means that the -delete action
takes place for children and some siblings before it takes place for some
item.   In the case of symbolic links this will mean that, at least some of
the time, the thing the link points to will have been deleted before the link
is examined by find.

That means that, at the time bar (in your example) is examined, "-type d" is
no longer true for it.  It's a broken symlink instead (-type l would match it)
and so it is not deleted since -type d is false.

I don't think this problem can be "solved" by special-casing directories, as
I'd imagine that analogous things apply to link counts or (sometimes)
directory sizes.

I think then that find is working as designed and that changing this aspect of
the design to change this behaviour would likely give rise to semantics that
are both inconsistent and much harder to explain (because of the
special-casing).

I'd recommend simply avoiding the use of -L with -delete (and in any case that
combination risks causing the deletion of unexpected  parts of the tree where
third parties can make symbolic links to / for example).

Please feel free to follow up if you disagree or you can see a simple
solution.   In the meantime I will work on some documentation updates to try
to make things clearer.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?46305>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]