Unix Technical Forum

Re: new in rm

This is a discussion on Re: new in rm within the lucky.openbsd.tech forums, part of the OpenBSD category; --> * Pierre-Yves Ritschard (pierre-yves@spootnik.org) wrote: > Same patch, but printing is done after succesfull removal. > Comments from ray ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > lucky.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2008, 01:34 PM
Pierre-Yves Ritschard
 
Posts: n/a
Default Re: new in rm

* Pierre-Yves Ritschard (pierre-yves@spootnik.org) wrote:
> Same patch, but printing is done after succesfull removal.
> Comments from ray have been taken into account.


According to Tom Cosgrove, man page diffs should have new sentences on a
new line, so here is the updated diff:

Index: rm.1
================================================== =================
RCS file: /space/release/cvs/src/bin/rm/rm.1,v
retrieving revision 1.25
diff -u -r1.25 rm.1
--- rm.1 14 Jun 2005 19:15:35 -0000 1.25
+++ rm.1 30 Jun 2006 07:41:22 -0000
@@ -42,7 +42,7 @@
.Sh SYNOPSIS
.Nm rm
.Op Fl f | Fl i
-.Op Fl dPRr
+.Op Fl dPRrv
.Ar file Op Ar ...
.Sh DESCRIPTION
The
@@ -104,6 +104,9 @@
.It Fl r
Equivalent to
.Fl R .
+.It Fl v
+Print each file path after successful removal.
+Useful when removing large directories.
.El
.Pp
The
Index: rm.c
================================================== =================
RCS file: /space/release/cvs/src/bin/rm/rm.c,v
retrieving revision 1.20
diff -u -r1.20 rm.c
--- rm.c 21 Mar 2006 20:28:52 -0000 1.20
+++ rm.c 29 Jun 2006 13:11:30 -0000
@@ -63,7 +63,7 @@

extern char *__progname;

-int dflag, eval, fflag, iflag, Pflag, stdin_ok;
+int dflag, eval, fflag, iflag, Pflag, vflag, stdin_ok;

int check(char *, char *, struct stat *);
void checkdot(char **);
@@ -88,7 +88,7 @@
setlocale(LC_ALL, "");

Pflag = rflag = 0;
- while ((ch = getopt(argc, argv, "dfiPRr")) != -1)
+ while ((ch = getopt(argc, argv, "dfiPRrv")) != -1)
switch(ch) {
case 'd':
dflag = 1;
@@ -108,6 +108,9 @@
case 'r': /* Compatibility. */
rflag = 1;
break;
+ case 'v':
+ vflag = 1;
+ break;
default:
usage();
}
@@ -208,8 +211,11 @@
case FTS_DP:
case FTS_DNR:
if (!rmdir(p->fts_accpath) ||
- (fflag && errno == ENOENT))
+ (fflag && errno == ENOENT)) {
+ if (vflag && errno != ENOENT)
+ printf("%s\n", p->fts_path);
continue;
+ }
break;

default:
@@ -217,8 +223,11 @@
if (!rm_overwrite(p->fts_accpath, NULL))
continue;
if (!unlink(p->fts_accpath) ||
- (fflag && errno == ENOENT))
+ (fflag && errno == ENOENT)) {
+ if (vflag && errno != ENOENT)
+ printf("%s\n", p->fts_path);
continue;
+ }
}
warn("%s", p->fts_path);
eval = 1;
@@ -267,6 +276,8 @@
if (rval && (!fflag || errno != ENOENT)) {
warn("%s", f);
eval = 1;
+ } else if (vflag) {
+ printf("%s\n", f);
}
}
}
@@ -422,6 +433,6 @@
void
usage(void)
{
- (void)fprintf(stderr, "usage: %s [-dfiPRr] file ...\n", __progname);
+ (void)fprintf(stderr, "usage: %s [-dfiPRrv] file ...\n", __progname);
exit(1);
}

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:27 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com