rm misbehavior
Paul Smith
paul at mad-scientist.net
Sun Dec 29 23:51:44 UTC 2024
On Sun, 2024-12-29 at 17:58 -0500, Paul Smith wrote:
> On Sun, 2024-12-29 at 14:25 -0800, MR ZenWiz wrote:
> > I even created a temporary directory to check this, and it deleted
> > the whole directory with 'rm <dirname>' (using the above function).
I will say, on a more abstract level, IMO it's a bad idea to rework a
fundamental command like "rm", in any way that makes it MORE safe.
What, you say? Don't make it MORE safe? Why?!?!
Because, if you start to rely on this behavior it will inevitably bite
you in a situation where you DON'T have this protection. For example
maybe you have used "sudo -s" to become root and root doesn't have your
special functions installed. Or maybe you use ssh to log into another
system, without your personal shell setup. Now you use "rm" in a
situation where you expect to be warned, but... you are not.
This is why I've always hated it that RHEL aliases rm to "rm -i" by
default.
It's just (IMO) a terrible, dangerous approach.
Instead, they should have created a new alias like "rmi" or something
and encouraged everyone to get used to running that instead of "rm".
Then at worst someone would get an "command not found" error if the
aliases are not available.
I urge you to consider a similar approach, with your function.
Cheers!
More information about the ubuntu-users
mailing list