summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2014-07-04 22:19:21 +0000
committereadler <eadler@FreeBSD.org>2014-07-04 22:19:21 +0000
commit6e29f84795d4884ec6d9cfe50f45177baa99f7df (patch)
treefe2c53522daf06e2ca338b764db7423c60668997 /usr.bin
parent1058eea813dd279b68c43fe4b9961f547fc431a8 (diff)
downloadFreeBSD-src-6e29f84795d4884ec6d9cfe50f45177baa99f7df.zip
FreeBSD-src-6e29f84795d4884ec6d9cfe50f45177baa99f7df.tar.gz
units(1): Add 'help' flag
- Add support for --help for compatibility - Make usage() static
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/units/units.12
-rw-r--r--usr.bin/units/units.c8
2 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/units/units.1 b/usr.bin/units/units.1
index c5a82ca..7e88efb 100644
--- a/usr.bin/units/units.1
+++ b/usr.bin/units/units.1
@@ -13,6 +13,8 @@
.Sh OPTIONS
The following options are available:
.Bl -tag -width indent
+.It Fl h No , Fl -help
+Show an overview of options
.It Fl f Ar filename No , Fl -file Ar filename
Specify the name of the units data file to load.
.It Fl q No , Fl -quiet
diff --git a/usr.bin/units/units.c b/usr.bin/units/units.c
index a0e3772..baf2a59 100644
--- a/usr.bin/units/units.c
+++ b/usr.bin/units/units.c
@@ -695,7 +695,7 @@ showanswer(struct unittype * have, struct unittype * want)
}
-void
+static void
usage(void)
{
fprintf(stderr,
@@ -704,6 +704,7 @@ usage(void)
}
static struct option longopts[] = {
+ {"help", no_argument, NULL, 'h'},
{"file", required_argument, NULL, 'f'},
{"quiet", no_argument, NULL, 'q'},
{"verbose", no_argument, NULL, 'v'},
@@ -728,7 +729,7 @@ main(int argc, char **argv)
quiet = false;
readfile = false;
- while ((optchar = getopt_long(argc, argv, "+f:qvUV", longopts, NULL)) != -1) {
+ while ((optchar = getopt_long(argc, argv, "+hf:qvUV", longopts, NULL)) != -1) {
switch (optchar) {
case 'f':
readfile = true;
@@ -753,6 +754,9 @@ main(int argc, char **argv)
printf("Units data file not found");
exit(0);
break;
+ case 'h':
+ /* FALLTHROUGH */
+
default:
usage();
}
OpenPOWER on IntegriCloud