simont |
Wed 2007-07-25 11:07 |
|
rm -F The build system at work occasionally generates entire directory trees full of files and directories with read-only permissions. Trying to delete such a directory is always a pain, because the procedure goes something like rm -rf directory rm gets EPERM on every file in a read-only subdirectory - swear
chmod -r +w directory chmod tries to take the r permission away from the nonexistent file +w - swear
chmod -R +w directory chmod now gets EPERM, because the previous invocation also successfully took the r permission away from directory - swear
chmod -R +rw directory rm -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. |
|