summaryrefslogtreecommitdiff
path: root/src/tr.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/tr.c
parent19272693f57193a57e5c4c66f65c791b2ee97378 (diff)
downloadcoreutils-2ff4fc16721b6caac08c16c851024b51b16a1824.tar.xz
add --version and --help
Diffstat (limited to 'src/tr.c')
-rw-r--r--src/tr.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/tr.c b/src/tr.c
index f4cc3a734..9010f4500 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include "getopt.h"
#include "system.h"
+#include "version.h"
#ifndef LONG_MAX
#define LONG_MAX 0x7FFFFFFF
@@ -286,12 +287,20 @@ static SET_TYPE in_delete_set[N_CHARS];
two specification strings and the delete switch is not given. */
static char xlate[N_CHARS];
+/* 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[] =
{
{"complement", no_argument, NULL, 'c'},
{"delete", no_argument, NULL, 'd'},
{"squeeze-repeats", no_argument, NULL, 's'},
{"truncate-set1", no_argument, NULL, 't'},
+ {"help", no_argument, &flag_help, 1},
+ {"version", no_argument, &flag_version, 1},
{NULL, 0, NULL, 0}
};
@@ -300,7 +309,7 @@ usage ()
{
fprintf (stderr, "\
Usage: %s [-cdst] [--complement] [--delete] [--squeeze-repeats]\n\
- [--truncate-set1] string1 [string2]\n",
+ [--truncate-set1] [--help] [--version] string1 [string2]\n",
program_name);
exit (2);
}
@@ -1656,6 +1665,12 @@ main (argc, argv)
}
}
+ if (flag_version)
+ fprintf (stderr, "%s\n", version_string);
+
+ if (flag_help)
+ usage ();
+
posix_pedantic = (getenv ("POSIXLY_CORRECT") != NULL);
non_option_args = argc - optind;