summaryrefslogtreecommitdiff
path: root/src/rm.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1993-04-02 04:26:26 +0000
committerJim Meyering <jim@meyering.net>1993-04-02 04:26:26 +0000
commitee871dbed84a671bad1217b23ad3802ab023e26c (patch)
treee35f1c605334d3d40c2ea1cd67fada6cd41d9d62 /src/rm.c
parent0a6061f1f9178df1bfddaff7b25dbf5393833096 (diff)
downloadcoreutils-ee871dbed84a671bad1217b23ad3802ab023e26c.tar.xz
Add --help and --version options.
Diffstat (limited to 'src/rm.c')
-rw-r--r--src/rm.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/rm.c b/src/rm.c
index 4b6c2d2eb..0dec9d133 100644
--- a/src/rm.c
+++ b/src/rm.c
@@ -21,6 +21,7 @@
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
+#include "version.h"
#ifdef _POSIX_SOURCE
/* POSIX.1 doesn't have inodes, so fake them to avoid lots of ifdefs. */
@@ -46,6 +47,9 @@ static int remove_file ();
static int rm ();
static void usage ();
+/* Name this program was run with. */
+char *program_name;
+
/* Path of file now being processed; extended as necessary. */
static char *pathname;
@@ -53,9 +57,6 @@ static char *pathname;
made larger when necessary, but never smaller. */
static int pnsize;
-/* Name this program was run with. */
-char *program_name;
-
/* If nonzero, display the name of each file removed. */
static int verbose;
@@ -76,6 +77,12 @@ static int unlink_dirs;
/* If nonzero, stdin is a tty. */
static int stdin_tty;
+/* 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 long_opts[] =
{
{"directory", no_argument, &unlink_dirs, 1},
@@ -83,6 +90,8 @@ static struct option const long_opts[] =
{"interactive", no_argument, NULL, 'i'},
{"recursive", no_argument, &recursive, 1},
{"verbose", no_argument, &verbose, 1},
+ {"help", no_argument, &flag_help, 1},
+ {"version", no_argument, &flag_version, 1},
{NULL, 0, NULL, 0}
};
@@ -129,6 +138,12 @@ main (argc, argv)
}
}
+ if (flag_version)
+ fprintf (stderr, "%s\n", version_string);
+
+ if (flag_help)
+ usage ();
+
if (optind == argc)
{
if (ignore_missing_files)