From owner-freebsd-bugs@FreeBSD.ORG Thu Mar 27 04:30:01 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 31332E11 for ; Thu, 27 Mar 2014 04:30:01 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (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 0E349A67 for ; Thu, 27 Mar 2014 04:30:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s2R4U0Kl006890 for ; Thu, 27 Mar 2014 04:30:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s2R4U0C7006889; Thu, 27 Mar 2014 04:30:00 GMT (envelope-from gnats) Resent-Date: Thu, 27 Mar 2014 04:30:00 GMT Resent-Message-Id: <201403270430.s2R4U0C7006889@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Edho Arief Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 05FABCBD for ; Thu, 27 Mar 2014 04:21:41 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CD4E7A30 for ; Thu, 27 Mar 2014 04:21:40 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s2R4LeTS005717 for ; Thu, 27 Mar 2014 04:21:40 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s2R4LeJs005714; Thu, 27 Mar 2014 04:21:40 GMT (envelope-from nobody) Message-Id: <201403270421.s2R4LeJs005714@cgiserv.freebsd.org> Date: Thu, 27 Mar 2014 04:21:40 GMT From: Edho Arief To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: bin/188008: [patch] Better(?) rm -If behavior (and other combination between -I, -i, and -f) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Mar 2014 04:30:01 -0000 >Number: 188008 >Category: bin >Synopsis: [patch] Better(?) rm -If behavior (and other combination between -I, -i, and -f) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Mar 27 04:30:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Edho Arief >Release: 10.0 >Organization: >Environment: FreeBSD izumi.myconan.net 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 16 22:34:59 UTC 2014 root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64 >Description: Currently, -I flag is completely unrelated with -f and -i flag despite having similar purpose (interactivity). It's especially weird when using -If (expected: no prompt). This patch changes the behavior so (-f|-i|-I) overrides each other flags (currently only between -i and -f). Sorry if duplicate. >How-To-Repeat: >Fix: Patch attached with submission follows: Index: rm.1 =================================================================== --- rm.1 (revision 263791) +++ rm.1 (working copy) @@ -68,6 +68,8 @@ .Fl f option overrides any previous .Fl i +and +.Fl I options. .It Fl i Request confirmation before attempting to remove each file, regardless of @@ -77,6 +79,8 @@ .Fl i option overrides any previous .Fl f +and +.Fl I options. .It Fl I Request confirmation once if more than three files are being removed or if a @@ -84,6 +88,13 @@ This is a far less intrusive option than .Fl i yet provides almost the same level of protection against mistakes. +The +.Fl I +option overrides any previous +.Fl f +and +.Fl i +options. .It Fl P Overwrite regular files before deleting them. Files are overwritten three times, first with the byte pattern 0xff, Index: rm.c =================================================================== --- rm.c (revision 263791) +++ rm.c (working copy) @@ -115,12 +115,16 @@ case 'f': fflag = 1; iflag = 0; + Iflag = 0; break; case 'i': fflag = 0; iflag = 1; + Iflag = 0; break; case 'I': + fflag = 0; + iflag = 0; Iflag = 1; break; case 'P': @@ -629,7 +633,7 @@ { (void)fprintf(stderr, "%s\n%s\n", - "usage: rm [-f | -i] [-dIPRrvWx] file ...", + "usage: rm [-f | -i | -I] [-dPRrvWx] file ...", " unlink file"); exit(EX_USAGE); } >Release-Note: >Audit-Trail: >Unformatted: