From owner-freebsd-questions@freebsd.org Sun Apr 17 23:00:08 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BC38B119A9 for ; Sun, 17 Apr 2016 23:00:08 +0000 (UTC) (envelope-from milios@ccsys.com) Received: from cargobay.net (cargobay.net [198.178.123.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3BF251AE2 for ; Sun, 17 Apr 2016 23:00:07 +0000 (UTC) (envelope-from milios@ccsys.com) Received: from [10.58.132.62] (mobile-166-172-120-117.mycingular.net [166.172.120.117]) by cargobay.net (Postfix) with ESMTPSA id B4D2A1DA; Sun, 17 Apr 2016 22:48:26 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: rm -rf -Mitigating the dangers From: Jake X-Mailer: iPhone Mail (13E238) In-Reply-To: <57140EA2.6020503@holgerdanske.com> Date: Sun, 17 Apr 2016 18:53:57 -0400 Cc: freebsd-questions@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <6743C8AB-D9FA-44C5-826F-1D7C094A9DBE@ccsys.com> References: <57140EA2.6020503@holgerdanske.com> To: David Christensen X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Apr 2016 23:00:08 -0000 > On Apr 17, 2016, at 6:30 PM, David Christensen = wrote: >=20 >> 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 m= y >> way:) >>=20 >> 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 t= o >> do with -rf is dangerous, yes? >>=20 >> Read input from sysadmin 3 times, looking strictly for their confirmation= >> before effecting the `rm -rf`. >>=20 >> Could it be that what I am smoking/drinking is the issue here or I have >> your support? LOL >=20 > I have this in my .bashrc: >=20 > alias rm=3D'rm -i --one-file-system' >=20 > So, an accidental 'rm -rf' should limit destruction to one file system. >=20 >=20 > Perhaps what you're looking for is a command-line equivalent of desktop tr= ash cans. STFW this is not a new idea and there are existing solutions. >=20 >=20 > David I for one cherish my God given constitutionally protected right to blast my d= arned 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 m= eant to do. Even testing for a tty on stdin or stdout cannot offer any strai= ghtforward way to guarantee adherence to expected behavior in times it's nec= essary. Perhaps a wrapper that simply sleeps for a few seconds first is viab= le but more complex logic would be necessary to avoid a horrific slowdown wh= en used within some sort of loop. An alias or function which is only sourced by your shell when entering inter= active mode would indeed be a good spot to place the proposed hypothetical s= olution.=