summaryrefslogtreecommitdiff
path: root/src/mv.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/mv.c
parent0a6061f1f9178df1bfddaff7b25dbf5393833096 (diff)
downloadcoreutils-ee871dbed84a671bad1217b23ad3802ab023e26c.tar.xz
Add --help and --version options.
Diffstat (limited to 'src/mv.c')
-rw-r--r--src/mv.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mv.c b/src/mv.c
index 9d28d4a87..91906e139 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -45,6 +45,7 @@
#include <sys/types.h>
#include "system.h"
#include "backupfile.h"
+#include "version.h"
#ifndef _POSIX_VERSION
uid_t geteuid ();
@@ -86,6 +87,12 @@ static int stdin_tty;
/* This process's effective user ID. */
static uid_t myeuid;
+/* 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_options[] =
{
{"backup", no_argument, NULL, 'b'},
@@ -95,6 +102,8 @@ static struct option const long_options[] =
{"update", no_argument, &update, 1},
{"verbose", no_argument, &verbose, 1},
{"version-control", required_argument, NULL, 'V'},
+ {"help", no_argument, &flag_help, 1},
+ {"version", no_argument, &flag_version, 1},
{NULL, 0, NULL, 0}
};
@@ -154,6 +163,12 @@ main (argc, argv)
if (argc < optind + 2)
usage ();
+ if (flag_version)
+ fprintf (stderr, "%s\n", version_string);
+
+ if (flag_help)
+ usage ();
+
if (make_backups)
backup_type = get_version (version);