[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
[bug #46305] Doing "find -L . -type d -delete" fails on symlinks to directories.
Sun, 01 Nov 2015 21:23:19 +0000
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)
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
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:
Message sent via/by Savannah