rm misbehavior
MR ZenWiz
mrzenwiz at gmail.com
Mon Dec 30 00:48:37 UTC 2024
On Sun, Dec 29, 2024 at 3:53 PM Paul Smith <paul at mad-scientist.net> wrote:
>
> 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!
>
Thanks to all for your input.
I modified the function to work "properly," though I deeply appreciate
the caution to avoid such things because of their non-universality.
I wrote this for my own primary desktop so I don't do stupid things
like what I actually did earlier today on the machine. (I am much more
careful elsewhere...) Turns out the files that were deleted are not
anything I really need or want to keep anymore anyway.
Apologies for the list noise.
MRZ
More information about the ubuntu-users
mailing list