# $Id: openbsd-rm_verbose.diff,v 1.1 2009/01/02 20:30:36 jcs Exp $ # # add a -v verbose flag to rm # # jcs@openbsd.org # Index: rm.1 =================================================================== RCS file: /cvs/src/bin/rm/rm.1,v retrieving revision 1.31 diff -u -p -r1.31 rm.1 --- rm.1 6 Jun 2007 00:08:57 -0000 1.31 +++ rm.1 2 Jan 2009 20:30:01 -0000 @@ -41,7 +41,7 @@ .Nd remove directory entries .Sh SYNOPSIS .Nm rm -.Op Fl dfiPRr +.Op Fl dfiPRrv .Ar .Sh DESCRIPTION The @@ -102,6 +102,8 @@ that directory is skipped. .It Fl r Equivalent to .Fl R . +.It Fl v +Print the name of the file before it is deleted. .El .Pp The Index: rm.c =================================================================== RCS file: /cvs/src/bin/rm/rm.c,v retrieving revision 1.22 diff -u -p -r1.22 rm.c --- rm.c 10 Jun 2008 17:14:16 -0000 1.22 +++ rm.c 2 Jan 2009 20:30:01 -0000 @@ -63,7 +63,7 @@ static char rcsid[] = "$OpenBSD: rm.c,v extern char *__progname; -int dflag, eval, fflag, iflag, Pflag, stdin_ok; +int dflag, eval, fflag, iflag, Pflag, stdin_ok, vflag; int check(char *, char *, struct stat *); void checkdot(char **); @@ -88,7 +88,7 @@ main(int argc, char *argv[]) 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 @@ main(int argc, char *argv[]) case 'r': /* Compatibility. */ rflag = 1; break; + case 'v': + vflag = 1; + break; default: usage(); } @@ -199,6 +202,9 @@ rm_tree(char **argv) continue; } + if (vflag) + printf("%s\n", p->fts_path); + /* * If we can't read or search the directory, may still be * able to remove it. Don't print out the un{read,search}able @@ -255,7 +261,11 @@ rm_file(char **argv) } if (!fflag && !check(f, f, &sb)) continue; - else if (S_ISDIR(sb.st_mode)) + + if (vflag) + printf("%s\n", f); + + if (S_ISDIR(sb.st_mode)) rval = rmdir(f); else { if (Pflag)