From ee871dbed84a671bad1217b23ad3802ab023e26c Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 2 Apr 1993 04:26:26 +0000 Subject: Add --help and --version options. --- src/install.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/install.c') diff --git a/src/install.c b/src/install.c index 4fccb8447..dd8b58cc7 100644 --- a/src/install.c +++ b/src/install.c @@ -59,9 +59,11 @@ #include #include #include "system.h" +#include "version.h" #include "modechange.h" #if !defined (isascii) || defined (STDC_HEADERS) +#undef isascii #define isascii(c) 1 #endif @@ -130,6 +132,12 @@ static int strip_files; /* If nonzero, install a directory instead of a regular file. */ static int dir_arg; +/* 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[] = { {"strip", no_argument, NULL, 's'}, @@ -137,6 +145,8 @@ static struct option const long_options[] = {"group", required_argument, NULL, 'g'}, {"mode", required_argument, NULL, 'm'}, {"owner", required_argument, NULL, 'o'}, + {"help", no_argument, &flag_help, 1}, + {"version", no_argument, &flag_version, 1}, {NULL, 0, NULL, 0} }; @@ -190,6 +200,12 @@ main (argc, argv) || (optind == argc - 1 && !dir_arg)) usage (); + if (flag_version) + fprintf (stderr, "%s\n", version_string); + + if (flag_help) + usage (); + if (symbolic_mode) { struct mode_change *change = mode_compile (symbolic_mode, 0); -- cgit v1.2.3-70-g09d2