summaryrefslogtreecommitdiff
path: root/src/ln.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/ln.c
parent0a6061f1f9178df1bfddaff7b25dbf5393833096 (diff)
downloadcoreutils-ee871dbed84a671bad1217b23ad3802ab023e26c.tar.xz
Add --help and --version options.
Diffstat (limited to 'src/ln.c')
-rw-r--r--src/ln.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/ln.c b/src/ln.c
index 3907399ee..673410363 100644
--- a/src/ln.c
+++ b/src/ln.c
@@ -25,6 +25,7 @@
#include <getopt.h>
#include "system.h"
#include "backupfile.h"
+#include "version.h"
int link (); /* Some systems don't declare this anywhere. */
@@ -41,6 +42,9 @@ void error ();
static void usage ();
static int do_link ();
+/* The name by which the program was run, for error messages. */
+char *program_name;
+
/* A pointer to the function used to make links. This will point to either
`link' or `symlink'. */
static int (*linkfunc) ();
@@ -60,8 +64,11 @@ static int verbose;
/* If nonzero, allow the superuser to make hard links to directories. */
static int hard_dir_link;
-/* The name by which the program was run, for error messages. */
-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 long_options[] =
{
@@ -73,6 +80,8 @@ static struct option const long_options[] =
{"symbolic", no_argument, &symbolic_link, 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}
};
@@ -142,6 +151,12 @@ main (argc, argv)
if (optind == argc)
usage ();
+ if (flag_version)
+ fprintf (stderr, "%s\n", version_string);
+
+ if (flag_help)
+ usage ();
+
if (make_backups)
backup_type = get_version (version);