[nycbug-talk] Safety Expansion for FreeBSD rm(1)
Ray Lai
nycbug at cyth.net
Mon Oct 1 23:56:00 EDT 2007
On Mon, Oct 01, 2007 at 11:17:22PM -0400, Jesse Callaway wrote:
> > Th .kshrc file that follows me from machine to machine checks to see if
> > vim is installed, and if it is, uses it.
> >
> > The reason I use vim is because it works just like vi but at the same time
> > has features and shortcuts that make what I want to do easier and quicker
> > to acomplish.
> >
> > Having a rm that first checks to make sure what you are doing is really what
> > you want to do is kinda the same principle as using vim. Allow me to
> > accomplish what I am think i wanted to do quicker and faster. (In case this,
> > its quicker because I don't have to restore /bin)
> >
> > Like I said, it is an interesting patch to rm that I can see being
> > extremenly useful in situations, but at the same time, it seems like
> > it is breaking some unwritten unix law
>
> you know, since I was the first to bite... I'll have to say that I'm
> the first to regret what I said. Afterthought is always good. Changing
> your mind is better.
>
> This is a good patch. Why not check ~/.rm? What's the harm? I was
> wrong. It won't break any scripts at all. It just makes the system
> more useable and in a friendly way. This is an improvement. And
> furthermore, it won't slow down anything if implemented in a halfway
> decent manner.
>
> Anyone care to join the dark side? I guess I'm on the fence about this
> as well... it seems, but I'm currently comfortable to one side.
I alias rm='rm -i', but every time I type "rm", I freeze, finger
hovering over the Enter key, staring hard at the command I just
typed out, until I am SURE. Then I hit Enter.
Instead of having .rm, you could just "chflags uchg $file"; achieves
the same thing without modifying /bin/rm. But the problem with
this approach is, you never know what is important until you lose
it. Good backups, aliasing rm, and thinking before hitting Enter
are tactics that protect all files. Not perfectly, but they do the
job.
For deleting some crazy globs, I generally first do "ls -d *.orig
a*.log *.bak" or whatever, before doing "rm -rf *.orig a*.log *.bak".
My instinct to be cautious whenever using rm has saved me more times
than the -i flag ever has. Windows's recycle bin, Norton's super
recycle bin, and Mac's trash can have never saved me; I rarely
delete anything by accident.
I am afraid of hitting send because I know Murphy's law will bite
me hard for this e-mail.
-Ray-
More information about the talk
mailing list