Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Apr 2016 18:53:57 -0400
From:      Jake <milios@ccsys.com>
To:        David Christensen <dpchrist@holgerdanske.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: rm -rf -Mitigating the dangers
Message-ID:  <6743C8AB-D9FA-44C5-826F-1D7C094A9DBE@ccsys.com>
In-Reply-To: <57140EA2.6020503@holgerdanske.com>
References:  <CAAdA2WNqWACnjiUSHhYWL1nEj=YGPPURqJHsAcjaXYacziXsfg@mail.gmail.com> <57140EA2.6020503@holgerdanske.com>

next in thread | previous in thread | raw e-mail | index | archive | help

> On Apr 17, 2016, at 6:30 PM, David Christensen <dpchrist@holgerdanske.com> wrote:
> 
>> On 04/17/2016 10:10 AM, Odhiambo Washington wrote:
>> I am wondering if I should place a feature request on this or just do it my
>> way:)
>> 
>> With great power comes great responsibility and as such I think there
>> should be a wrapper around rm to warn sysadmins that what they are about to
>> do with -rf is dangerous, yes?
>> 
>> Read input from sysadmin 3 times, looking strictly for their confirmation
>> before effecting the `rm -rf`.
>> 
>> Could it be that what I am smoking/drinking is the issue here or I have
>> your support? LOL
> 
> I have this in my .bashrc:
> 
>    alias rm='rm -i --one-file-system'
> 
> So, an accidental 'rm -rf' should limit destruction to one file system.
> 
> 
> Perhaps what you're looking for is a command-line equivalent of desktop trash cans.  STFW this is not a new idea and there are existing solutions.
> 
> 
> David

I for one cherish my God given constitutionally protected right to blast my darned foot clear off my bloody leg with one twitch of a hair trigger. :)

A wrapper would be problematic. Too many scripts rely on rm doing what it's meant to do. Even testing for a tty on stdin or stdout cannot offer any straightforward way to guarantee adherence to expected behavior in times it's necessary. Perhaps a wrapper that simply sleeps for a few seconds first is viable but more complex logic would be necessary to avoid a horrific slowdown when used within some sort of loop.

An alias or function which is only sourced by your shell when entering interactive mode would indeed be a good spot to place the proposed hypothetical solution.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6743C8AB-D9FA-44C5-826F-1D7C094A9DBE>