aboutsummaryrefslogtreecommitdiffstats
path: root/src/paste.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1993-04-29 05:26:22 +0000
committerJim Meyering <jim@meyering.net>1993-04-29 05:26:22 +0000
commit2ff4fc16721b6caac08c16c851024b51b16a1824 (patch)
tree34d2aba87f63f370d03812e5c8660c2e84b3908e /src/paste.c
parentadd --version and --help options (diff)
downloadcoreutils-2ff4fc16721b6caac08c16c851024b51b16a1824.tar.gz
coreutils-2ff4fc16721b6caac08c16c851024b51b16a1824.zip
add --version and --help
Diffstat (limited to 'src/paste.c')
-rw-r--r--src/paste.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/paste.c b/src/paste.c
index 3cd95d368..bc9b7e5c0 100644
--- a/src/paste.c
+++ b/src/paste.c
@@ -42,6 +42,7 @@
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
+#include "version.h"
void error ();
char *xmalloc ();
@@ -77,10 +78,18 @@ static char *delims;
/* A pointer to the character after the end of `delims'. */
static char *delim_end;
+/* 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 longopts[] =
{
{"serial", no_argument, 0, 's'},
{"delimiters", required_argument, 0, 'd'},
+ {"help", no_argument, &flag_help, 1},
+ {"version", no_argument, &flag_version, 1},
{0, 0, 0, 0}
};
@@ -104,6 +113,9 @@ main (argc, argv)
{
switch (optc)
{
+ case 0:
+ break;
+
case 'd':
/* Delimiter character(s). */
if (optarg[0] == '\0')
@@ -120,6 +132,12 @@ main (argc, argv)
}
}
+ if (flag_version)
+ fprintf (stderr, "%s\n", version_string);
+
+ if (flag_help)
+ usage ();
+
if (optind == argc)
argv[argc++] = "-";
@@ -453,7 +471,7 @@ usage ()
{
fprintf (stderr, "\
Usage: %s [-s] [-d delim-list] [--serial] [--delimiters=delim-list]\n\
- [file...]\n",
+ [--help] [--version] [file...]\n",
program_name);
exit (1);
}