The build system at work occasionally generates entire directory trees full of files and directories with read-
rm -rf directoryrmgetsEPERMon every file in a read-only subdirectory - swear
chmod -r +w directorychmodtries to take the r permission away from the nonexistent file+w- swear
chmod -R +w directorychmodnow getsEPERM, because the previous invocation also successfully took the r permission away fromdirectory- swear
chmod -R +rw directoryrm -rf directory
… and since I mostly try to avoid generating these directories in the first place, this happens just infrequently enough that the next time I've forgotten all the pitfalls and do pretty much the same thing again.
What I want is for rm to support the -F option, which is like -f except that it also authorises rm to temporarily restore write permission (if permitted to) on any directory from which the lack of it is preventing it from deleting a file. Or possibly it should only be allowed to do that if the directory is one it's planning to delete completely later in the operation anyway; that might be safer. But either way, the point is, if the Unix permissions system makes it possible in principle to arrange for the directory not to be there any more, then I want to be able to get rm to just do so, by any means necessary short of requesting the root password, and not bother me with trivial details of how.