diff options
author | Jim Meyering <jim@meyering.net> | 1993-04-02 04:26:26 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1993-04-02 04:26:26 +0000 |
commit | ee871dbed84a671bad1217b23ad3802ab023e26c (patch) | |
tree | e35f1c605334d3d40c2ea1cd67fada6cd41d9d62 /src/chown.c | |
parent | 0a6061f1f9178df1bfddaff7b25dbf5393833096 (diff) | |
download | coreutils-ee871dbed84a671bad1217b23ad3802ab023e26c.tar.xz |
Add --help and --version options.
Diffstat (limited to 'src/chown.c')
-rw-r--r-- | src/chown.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/chown.c b/src/chown.c index 37a881e2f..e693e662a 100644 --- a/src/chown.c +++ b/src/chown.c @@ -35,6 +35,7 @@ #include <grp.h> #include <getopt.h> #include "system.h" +#include "version.h" #ifndef _POSIX_VERSION struct passwd *getpwnam (); @@ -81,6 +82,12 @@ static char *username; /* The name of the group to which ownership of the files is being given. */ static char *groupname; +/* 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'}, @@ -88,6 +95,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} }; @@ -131,6 +140,12 @@ main (argc, argv) if (optind >= argc - 1) usage (); + if (flag_version) + fprintf (stderr, "%s\n", version_string); + + if (flag_help) + usage (); + e = parse_user_spec (argv[optind], &user, &group, &username, &groupname); if (e) error (1, 0, "%s: %s", argv[optind], e); |