4 ms·
It always scares me when people automatically add -rf after typing rm no matter what they're doing. How do you even get into that habit in the first place?
by lexicality 6y ago
It always scares me when people automatically add -rf after typing rm no matter what they're doing. How do you even get into that habit in the first place?
- kazinator 6y agoIf I were to guess, how one might get into that habit is being annoyed by error messages: "cannot remove 'foo': is a directory" Just remove the darned object you're given as an argument using the appropriate implementation for its type. "rm: remove write-protected regular file 'foo'?" The rules are that if the directory is writable, the object can be deleted. Though you called stat to figure out it's a regular file, you didn't notice the link count: I have two more hard links to the file in the same directory, and one elsewhere. But, yes, unlink it.
- NikolaeVarius 6y agoI have this bad habit. Because in linux everything is a file, so screw you rm stop telling me i can't delete that directory. Its just a file that points to another directory. Its messing up my flow.
- accelbred 6y agoIf git repositories didn't need a -f to rm I wouldn't, but its a habit from git repos giving errors.
- lovehashbrowns 6y agoStarting out with that behavior because it comes up a lot in tutorials, probably. And then not making a typo mistake earlier on to learn the lesson to not do that with every rm command. I'd probably have that habit if I didn't once delete everything in a /bin directory early on in my learning, and luckily it was in a VM.