== Unix's mistake with _rm_ and directories Welcome to Unix, land of: .pn prewrap on > ; rm thing > rm: cannot remove 'thing': Is a directory > ; rmdir thing > ; (And also _rm_ may only be telling you half the story, because you can have your _rmdir_ fail with '_rmdir: failed to remove 'thing': Directory not empty_'. Gee thanks both of you.) Let me be blunt here: this is Unix exercising robot logic. Unix knows perfectly well what you want to do, it's perfectly safe to do so, and yet Unix refuses to do it (or tell you the full problem) because you didn't use the right command. Rm will even remove directories if you just tell it '_rm -r thing_', although this is more dangerous than _rmdir_. [[Once upon a time UnixDirectoryFiddlingHistory]] _rm_ had almost no choice but to do this because removing directories took special magic and special permissions (as '_._' and '_.._' and the directory tree were maintained in user space). Those days are long over, and with them all of the logic that would have justified keeping this _rm_ (mis)feature. It lingers on only as another piece of [[Unix fossilization UnixFossilizationExample]]. (This restriction is not even truly Unixy; [[per Norman Wilson https://twitter.com/oclsc/status/574119880598929408]], Research Unix's 8th edition removed the restriction, so the very heart of Unix fixed this. Sadly very little from Research Unix V8, V9, and V10 ever made it out into the world.) PS: Some people will now say that the Single Unix Specification (and POSIX) does not permit _rm_ to behave this way. My view is 'nuts to the SUS on this'. Many parts of real Unixes are already not strictly POSIX compliant, so if you really have to have this you can add code to _rm_ to behave in a strictly POSIX compliant mode if some environment variable is set. (This leads into another rant.) (I will reluctantly concede that having _unlink(2)_ still fail on directories instead of turning into _rmdir(2)_ is probably safest, even if I don't entirely like it either. Some program is probably counting on the behavior and there's not too much reason to change it. Rm is different in part because it is used by people; _unlink(2)_ is not directly. Yes, I'm waving my hands a bit.)