vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Thu, Jun 29, 2006 at 01:18:16PM +0200, Pierre-Yves Ritschard wrote: > Same patch, but removed print_file_name function and "Removing:" message > the message is printed before removing in every case and even when > calling rmdir (which wasn't done previously). I also updated > documentation for rm(1). Inline. > 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 09:53:16 -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(); > } > @@ -157,6 +160,8 @@ > if (!(fts = fts_open(argv, flags, NULL))) > err(1, NULL); > while ((p = fts_read(fts)) != NULL) { > + if (vflag) > + printf("%s\n", p->fts_path); > switch (p->fts_info) { > case FTS_DNR: > if (!fflag || p->fts_errno != ENOENT) { > @@ -256,13 +261,17 @@ > } > if (!fflag && !check(f, f, &sb)) > continue; > - else if (S_ISDIR(sb.st_mode)) > - rval = rmdir(f); > else { > - if (Pflag) > - if (!rm_overwrite(f, &sb)) > - continue; > - rval = unlink(f); > + if (vflag) > + printf("%s\n", f); > + if (S_ISDIR(sb.st_mode)) > + rval = rmdir(f); > + else { > + if (Pflag) > + if (!rm_overwrite(f, &sb)) > + continue; > + rval = unlink(f); > + } Why the additional level of indentation? And as djm@ suggested, ``It should probably print the file/directory name *after* successfully removing it.'' > } > if (rval && (!fflag || errno != ENOENT)) { > warn("%s", f); > @@ -422,6 +431,6 @@ > void > usage(void) > { > - (void)fprintf(stderr, "usage: %s [-dfiPRr] file ...\n", __progname); > + (void)fprintf(stderr, "usage: %s [-dfiPRrv] file ...\n", __progname); > exit(1); > } > 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 29 Jun 2006 09:44:02 -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,10 @@ > .It Fl r > Equivalent to > .Fl R . > +.Pp > +.It Fl v > +Print each file path before removal. Useful when removing large > +directories. You don't need a .Pp right before a .It. -Ray- > .El > .Pp > The |
| Thread Tools | |
| Display Modes | |
|
|