From 87fa23e6417d7d1938b72e872d779ae7225a5aa4 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 12 Oct 1993 01:52:24 +0000 Subject: merge with 1.8.1b --- src/tee.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'src/tee.c') diff --git a/src/tee.c b/src/tee.c index 941507fec..b107ee053 100644 --- a/src/tee.c +++ b/src/tee.c @@ -21,7 +21,9 @@ #include #include #include + #include "system.h" +#include "version.h" char *xmalloc (); void error (); @@ -38,13 +40,31 @@ static int ignore_interrupts; /* The name that this program was run with. */ char *program_name; +/* If non-zero, display usage information and exit. */ +static int show_help; + +/* If non-zero, print the version on standard output and exit. */ +static int show_version; + static struct option const long_options[] = { {"append", no_argument, NULL, 'a'}, + {"help", no_argument, &show_help, 1}, {"ignore-interrupts", no_argument, NULL, 'i'}, + {"version", no_argument, &show_version, 1}, {NULL, 0, NULL, 0} }; +static void +usage () +{ + fprintf (stderr, "\ +Usage: %s [{--help,--version}] [-ai] [--append]\n\ + [--ignore-interrupts] [file...]\n", + program_name); + exit (1); +} + void main (argc, argv) int argc; @@ -62,20 +82,31 @@ main (argc, argv) { switch (optc) { + case 0: + break; + case 'a': append = 1; break; + case 'i': ignore_interrupts = 1; break; + default: - fprintf (stderr, "\ -Usage: %s [-ai] [--append] [--ignore-interrupts] [file...]\n", - program_name); - exit (1); + usage (); } } + if (show_version) + { + printf ("%s\n", version_string); + exit (0); + } + + if (show_help) + usage (); + if (ignore_interrupts) { #ifdef _POSIX_VERSION -- cgit v1.2.3-70-g09d2