From nobody@FreeBSD.org  Thu Mar 27 04:21:41 2014
Return-Path: <nobody@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 05FABCBD
	for <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <edho@live.jp>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] Better(?) rm -If behavior (and other combination between -I, -i, and -f)
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         188008
>Category:       bin
>Synopsis:       [patch] rm(1): 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:  Thu Mar 27 07:54:32 UTC 2014
>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:
