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/chmod.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/chmod.c') diff --git a/src/chmod.c b/src/chmod.c index 3df4b99ab..de93b0f0c 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -28,6 +28,7 @@ #include #include "modechange.h" #include "system.h" +#include "version.h" int lstat (); @@ -57,6 +58,12 @@ static int verbose; /* If nonzero, describe only modes that change. */ static int changes_only; +/* 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[] = { {"recursive", no_argument, 0, 'R'}, @@ -64,6 +71,8 @@ static struct option const long_options[] = {"silent", no_argument, 0, 'f'}, {"quiet", no_argument, 0, 'f'}, {"verbose", no_argument, 0, 'v'}, + {"help", no_argument, &flag_help, 1}, + {"version", no_argument, &flag_version, 1}, {0, 0, 0, 0} }; @@ -136,6 +145,12 @@ main (argc, argv) if (optind >= argc) usage (); + if (flag_version) + fprintf (stderr, "%s\n", version_string); + + if (flag_help) + usage (); + changes = mode_compile (argv[modeind], MODE_MASK_EQUALS | MODE_MASK_PLUS | MODE_MASK_MINUS); if (changes == MODE_INVALID) -- cgit v1.2.3-70-g09d2