Subject: rm -v extension
To: None <tech-userlevel@netbsd.org>
From: Jason R. Fink <jrf@adresearch.com>
List: tech-userlevel
Date: 12/29/2002 17:19:01
--x+6KMIRAuhnl3hBn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hello,
Attached is a patch with the -v flag enabled for rm plus
accompanying manual page. My version of this is somewhat
different than FreeBSDs (not too much) so some testing
would be great. I have tested it myself and it appears
to work, but I really do not want to commit it without
some feedback. Thanks,
j
--
Jay Fink http://pyxis.homeunix.net/
NetBSD Developer http://www.netbsd.org/
Senior SysAdmin/Programmer, Ipsos http://www.ipsos.com/
--x+6KMIRAuhnl3hBn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="rm.diff"
Index: rm.1
===================================================================
RCS file: /cvsroot/src/bin/rm/rm.1,v
retrieving revision 1.14
diff -u -r1.14 rm.1
--- rm.1 2002/05/02 13:14:23 1.14
+++ rm.1 2002/12/29 22:15:10
@@ -45,7 +45,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl f | Fl i
-.Op Fl dPRrW
+.Op Fl dPRrvW
.Ar
.Sh DESCRIPTION
The
@@ -101,6 +101,10 @@
.It Fl r
Equivalent to
.Fl R .
+.It Fl v
+Cause
+.Nm
+to be verbose, showing files as they are processed.
.It Fl W
Attempts to undelete the named files.
Currently, this option can only be used to recover
@@ -155,3 +159,8 @@
utility is expected to be
.St -p1003.2
compatible.
+.Pp
+The
+.Fl v
+option is an extension to
+.St -p1003.2
Index: rm.c
===================================================================
RCS file: /cvsroot/src/bin/rm/rm.c,v
retrieving revision 1.31
diff -u -r1.31 rm.c
--- rm.c 2002/11/05 04:49:05 1.31
+++ rm.c 2002/12/29 22:15:10
@@ -62,7 +62,7 @@
#include <string.h>
#include <unistd.h>
-int dflag, eval, fflag, iflag, Pflag ,stdin_ok, Wflag;
+int dflag, eval, fflag, iflag, Pflag ,stdin_ok, vflag, Wflag;
int check(char *, char *, struct stat *);
void checkdot(char **);
@@ -96,7 +96,7 @@
(void)setlocale(LC_ALL, "");
Pflag = rflag = 0;
- while ((ch = getopt(argc, argv, "dfiPRrW")) != -1)
+ while ((ch = getopt(argc, argv, "dfiPRrvW")) != -1)
switch (ch) {
case 'd':
dflag = 1;
@@ -116,6 +116,9 @@
case 'r': /* Compatibility. */
rflag = 1;
break;
+ case 'v':
+ vflag = 1;
+ break;
case 'W':
Wflag = 1;
break;
@@ -226,12 +229,16 @@
case FTS_DNR:
if (!rmdir(p->fts_accpath) ||
(fflag && errno == ENOENT))
+ if (vflag)
+ (void)printf("%s\n", p->fts_path);
continue;
break;
case FTS_W:
if (!undelete(p->fts_accpath) ||
(fflag && errno == ENOENT))
+ if (vflag)
+ (void)printf("%s\n", p->fts_path);
continue;
break;
@@ -240,6 +247,8 @@
rm_overwrite(p->fts_accpath, NULL);
if (!unlink(p->fts_accpath) ||
(fflag && NONEXISTENT(errno)))
+ if (vflag)
+ (void)printf("%s\n", p->fts_path);
continue;
}
warn("%s", p->fts_path);
@@ -298,6 +307,8 @@
warn("%s", f);
eval = 1;
}
+ if (vflag)
+ (void)printf("%s\n", f);
}
}
@@ -430,7 +441,7 @@
usage(void)
{
- (void)fprintf(stderr, "usage: %s [-f|-i] [-dPRrW] file ...\n",
+ (void)fprintf(stderr, "usage: %s [-f|-i] [-dPRrvW] file ...\n",
getprogname());
exit(1);
/* NOTREACHED */
--x+6KMIRAuhnl3hBn--