OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: rm: ignorance isn't bliss

From: Superingo (rootsaatgutzwerg.de)
Date: Fri Oct 17 2014 - 19:16:39 CDT


Hi Ingo,

thanks for the very quick reply. (Are you sure, you are not needlessly pissed,
because I used the "Superingo"-From? This was not meant to affect you or any
other real living being! So sorry, if misunderstood!)

> Hi Superingo,
>
> Superingo wrote on Fri, Oct 17, 2014 at 09:19:45PM +0200:
>
> > I just fatfingered a ';' into a ',':
> >
> > $ rm a.out, cc mind.c
> >
> > rm: a.out,: No such file or directory
> > rm: cc: No such file or directory
> >
> > In full POSIX-conformance I lost my mind.
> > Coincidentally I had an idea.
> > What do you think?
>
> Here is what a standard Ingo would think:
>
> Don't casually type multiple commands on the same line,
> in particular, don't add needless stuff after potentially
> dangerous commands like rm(1). Hitting "Enter" after each
> interactive command often helps to mitigate the damage done
> by catastrophic typos.

It is not so uncommon, to use sequences like this, for repeating mildly
complex tasks from shell-history.

> If you want to disregard that advice, use "cmd && cmd" rather
> than "cmd; cmd" - it's safer with respect to failures and
> chances are typos will more readily meet the eye.

This would have saved the day in this particular instance. But "&&" doesn't
mean the same thing as ";", I would have to use "rm -f" which also implies
other stuff...

> Consider using
> alias rm='rm -i'
> Admittedly, that's a matter of taste, and it can be tedious
> now and then, but it does help me to prevent such havoc.

WAY too tedious for this usecase.

> Your proposal is not going to solve your problem.
> You are not trying to tell me that you plan to type 'rm -x'
> for each and every removal in the future, right?
> And even if you do plan on doing that, it's easy to forget.

I considered "alias rm='rm -x'" in a profile, and planned to remember adding
-f when needed.

> Finally, your proposal is a terrible idea.
> We don't gratuitiously add knobs to POSIX tools.
>
> * In NetBSD, FreeBSD, and Dragonfly, -x means "do not cross mount
> points" (since last year).
> * In illumos and in the GNU coreutils, there is no -x option.

My mistake, I had not checked the most recent versions of everything.
It should of course not be -x but something unused.

> So, this would be completely non-standard, conflicting, and
> not very useful.

Well, the conflicting part could be easily fixed. I totally disagree on the
useful part. Please let me place a short rant regarding the standard:

The whole purpose of the rm command is to unrecoverably delete data on the
user's command. What should it do, if while doing it's job, it suddenly
becomes clear, that the user's command is not the user's intend (fatfingering
or not knowing what's in the file system)? Standard and tradition dictates
"YEAH! GO ON! KILL! MISSION ACCOMPLISHED! MWUAHAHAHA!!". IMHO, without decades
of brainwashing, most people would agree this would be a good opportunity to
abort the job!

Of course standards and tradition can not be changed easily, so I proposed
the introduction of a nonstandard switch, which would enable sane behaviour
to save our precious data from our sins.

> No thanks!

Thanks for listening. I feel much better.