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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| * 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); } |