diff options
author | Jim Meyering <jim@meyering.net> | 1993-04-29 05:26:22 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1993-04-29 05:26:22 +0000 |
commit | 2ff4fc16721b6caac08c16c851024b51b16a1824 (patch) | |
tree | 34d2aba87f63f370d03812e5c8660c2e84b3908e /src/tail.c | |
parent | 19272693f57193a57e5c4c66f65c791b2ee97378 (diff) | |
download | coreutils-2ff4fc16721b6caac08c16c851024b51b16a1824.tar.xz |
add --version and --help
Diffstat (limited to 'src/tail.c')
-rw-r--r-- | src/tail.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/tail.c b/src/tail.c index 138c22894..d3bc8cd62 100644 --- a/src/tail.c +++ b/src/tail.c @@ -50,6 +50,7 @@ #include <sys/types.h> #include <signal.h> #include "system.h" +#include "version.h" /* Number of items to tail. */ #define DEFAULT_NUMBER 10 @@ -111,6 +112,12 @@ char *program_name; /* Nonzero if we have ever read standard input. */ static int have_read_stdin; +/* 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[] = { {"bytes", required_argument, NULL, 'c'}, @@ -119,6 +126,8 @@ static struct option const long_options[] = {"quiet", no_argument, NULL, 'q'}, {"silent", no_argument, NULL, 'q'}, {"verbose", no_argument, NULL, 'v'}, + {"help", no_argument, &flag_help, 1}, + {"version", no_argument, &flag_version, 1}, {NULL, 0, NULL, 0} }; @@ -208,6 +217,9 @@ main (argc, argv) { switch (c) { + case 0: + break; + case 'c': unit_size = 1; parse_unit (optarg); @@ -244,6 +256,12 @@ main (argc, argv) } } + if (flag_version) + fprintf (stderr, "%s\n", version_string); + + if (flag_help) + usage (); + if (number == -1) number = DEFAULT_NUMBER; @@ -987,7 +1005,8 @@ usage () { fprintf (stderr, "\ Usage: %s [-c [+]N[bkm]] [-n [+]N] [-fqv] [--bytes=[+]N[bkm]] [--lines=[+]N]\n\ - [--follow] [--quiet] [--silent] [--verbose] [file...]\n\ + [--follow] [--quiet] [--silent] [--verbose] [--help] [--version]\n\ + [file...]\n\ %s [{-,+}Nbcfklmqv] [file...]\n", program_name, program_name); exit (1); } |