summaryrefslogtreecommitdiff
path: root/src/tee.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1993-10-12 01:52:24 +0000
committerJim Meyering <jim@meyering.net>1993-10-12 01:52:24 +0000
commit87fa23e6417d7d1938b72e872d779ae7225a5aa4 (patch)
tree0fcc68f9cdf7315d09d5836df0f261e3d6b8c13a /src/tee.c
parentf12b53b2ce8f0bb0dd28a290f9b27490ef4599a9 (diff)
downloadcoreutils-87fa23e6417d7d1938b72e872d779ae7225a5aa4.tar.xz
merge with 1.8.1b
Diffstat (limited to 'src/tee.c')
-rw-r--r--src/tee.c39
1 files changed, 35 insertions, 4 deletions
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 <sys/types.h>
#include <signal.h>
#include <getopt.h>
+
#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