I was discussing with a friend trying to figure out why rm command does not, for example, check if the path is to a file or a folder automatically and delete it recursively, by default, if necessary. Without the needs of the "-r" all the time for a pretty common task. I know that I could put an alias for that. But what I really want is to know the reason (I think that exists a good one, I just don't know).
For the actual reason you should ask the author(s). I can only tell you this is a very good practice:
The Westinghouse system uses air pressure to charge air reservoirs (tanks) on each car. Full air pressure signals each car to release the brakes. A reduction or loss of air pressure signals each car to apply its brakes, using the compressed air in its reservoirs.
It means the default state is the brake being applied. You need an effort to release it and put the train in a potentially dangerous state.
Of course it doesn't explain why there are the two
rm modes (recursive and non-recursive) in the first place. Maybe this is what you ask. However, as they are, making the safer one the default was The Right Thing to do.
A second hypothesis would be that the recursive mode was an afterthought.
After all plain
rm isn't safe either. And it's not necessarily even safer, as different files are not equally important or irreplacable. What would you rather delete: a directory cloned from Github with the
-r flag or
/boot/vmlinuz* without the
rm you shoot yourself in the foot. But with
rm -r you shoot every foot you see, if you're lucky none of those feet are one of your own.
rm -r does something completely different than plain
rm, it has to unlink(2) every single file walking down the tree and then rmdir(2) the empty directories.