diff options
author | des <des@FreeBSD.org> | 2004-03-21 04:56:06 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2004-03-21 04:56:06 +0000 |
commit | 88d86ea2c1f760bcc25bd079a4fa143a5ac1e2d3 (patch) | |
tree | 5bd3e6d70752d737e23a02e8e58f80fd712e3949 | |
parent | 854f282025a130c71ad6f9238e382863be7add59 (diff) | |
download | FreeBSD-src-88d86ea2c1f760bcc25bd079a4fa143a5ac1e2d3.zip FreeBSD-src-88d86ea2c1f760bcc25bd079a4fa143a5ac1e2d3.tar.gz |
Add a -v (verbose) option.
-rw-r--r-- | bin/rmdir/rmdir.1 | 6 | ||||
-rw-r--r-- | bin/rmdir/rmdir.c | 33 |
2 files changed, 26 insertions, 13 deletions
diff --git a/bin/rmdir/rmdir.1 b/bin/rmdir/rmdir.1 index 018b793..3950fa3 100644 --- a/bin/rmdir/rmdir.1 +++ b/bin/rmdir/rmdir.1 @@ -35,7 +35,7 @@ .\" @(#)rmdir.1 8.1 (Berkeley) 5/31/93 .\" $FreeBSD$ .\" -.Dd May 31, 1993 +.Dd March 21, 2004 .Dt RMDIR 1 .Os .Sh NAME @@ -43,7 +43,7 @@ .Nd remove directories .Sh SYNOPSIS .Nm -.Op Fl p +.Op Fl pv .Ar directory ... .Sh DESCRIPTION The @@ -72,6 +72,8 @@ starting with the last most component. (See .Xr rm 1 for fully non-discriminant recursive removal.) +.It Fl v +Be verbose, listing each directory as it is removed. .El .Pp The diff --git a/bin/rmdir/rmdir.c b/bin/rmdir/rmdir.c index 606cf7e..aa70cba 100644 --- a/bin/rmdir/rmdir.c +++ b/bin/rmdir/rmdir.c @@ -52,21 +52,25 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <unistd.h> -int rm_path(char *); -void usage(void); +static int rm_path(char *); +static void usage(void); + +static int pflag; +static int vflag; int main(int argc, char *argv[]) { int ch, errors; - int pflag; - pflag = 0; - while ((ch = getopt(argc, argv, "p")) != -1) + while ((ch = getopt(argc, argv, "pv")) != -1) switch(ch) { case 'p': pflag = 1; break; + case 'v': + vflag = 1; + break; case '?': default: usage(); @@ -78,17 +82,22 @@ main(int argc, char *argv[]) usage(); for (errors = 0; *argv; argv++) { - if (rmdir(*argv) < 0) { - warn("%s", *argv); - errors = 1; - } else if (pflag) + if (pflag) { errors |= rm_path(*argv); + } else { + if (rmdir(*argv) < 0) { + warn("%s", *argv); + errors = 1; + } + if (vflag) + printf("%s\n", *argv); + } } exit(errors); } -int +static int rm_path(char *path) { char *p; @@ -107,12 +116,14 @@ rm_path(char *path) warn("%s", path); return (1); } + if (vflag) + printf("%s\n", path); } return (0); } -void +static void usage(void) { |