diff options
author | Jim Meyering <jim@meyering.net> | 1993-04-02 04:26:26 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1993-04-02 04:26:26 +0000 |
commit | ee871dbed84a671bad1217b23ad3802ab023e26c (patch) | |
tree | e35f1c605334d3d40c2ea1cd67fada6cd41d9d62 /src/rmdir.c | |
parent | 0a6061f1f9178df1bfddaff7b25dbf5393833096 (diff) | |
download | coreutils-ee871dbed84a671bad1217b23ad3802ab023e26c.tar.xz |
Add --help and --version options.
Diffstat (limited to 'src/rmdir.c')
-rw-r--r-- | src/rmdir.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/rmdir.c b/src/rmdir.c index 35bd7d652..aaaeb4df6 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -26,6 +26,7 @@ #include <getopt.h> #include <sys/types.h> #include "system.h" +#include "version.h" void error (); void strip_trailing_slashes (); @@ -33,15 +34,23 @@ void strip_trailing_slashes (); static void remove_parents (); static void usage (); +/* The name this program was run with. */ +char *program_name; + /* If nonzero, remove empty parent directories. */ static int empty_paths; -/* The name this program was run with. */ -char *program_name; +/* If non-zero, display usage information and exit. */ +static int flag_help; + +/* If non-zero, print the version on standard error. */ +static int flag_version; static struct option const longopts[] = { {"path", no_argument, &empty_paths, 1}, + {"help", no_argument, &flag_help, 1}, + {"version", no_argument, &flag_version, 1}, {NULL, 0, NULL, 0} }; @@ -72,7 +81,13 @@ main (argc, argv) if (optind == argc) usage (); - + + if (flag_version) + fprintf (stderr, "%s\n", version_string); + + if (flag_help) + usage (); + for (; optind < argc; ++optind) { /* Stripping slashes is harmless for rmdir; |