diff options
author | eadler <eadler@FreeBSD.org> | 2014-04-14 16:55:09 +0000 |
---|---|---|
committer | eadler <eadler@FreeBSD.org> | 2014-04-14 16:55:09 +0000 |
commit | f6ef22809d6b1ad477e43f7b58960bbb23143f76 (patch) | |
tree | 9139d0d96161c938f2826df3804e576889c7eb97 /usr.bin | |
parent | 25d806296075b2fe0216ad9aa0de732862a2edbe (diff) | |
download | FreeBSD-src-f6ef22809d6b1ad477e43f7b58960bbb23143f76.zip FreeBSD-src-f6ef22809d6b1ad477e43f7b58960bbb23143f76.tar.gz |
units(1): Add U option
For increased compatibility with GNU units: support a -U option which tests for the
existence of the default units file and prints it to the screen.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/units/units.1 | 9 | ||||
-rw-r--r-- | usr.bin/units/units.c | 11 |
2 files changed, 16 insertions, 4 deletions
diff --git a/usr.bin/units/units.1 b/usr.bin/units/units.1 index 2ce1000..4b485f3 100644 --- a/usr.bin/units/units.1 +++ b/usr.bin/units/units.1 @@ -1,5 +1,5 @@ .\" $FreeBSD$ -.Dd July 14, 1993 +.Dd April 14, 2014 .Dt UNITS 1 .Os .Sh NAME @@ -8,7 +8,7 @@ .Sh SYNOPSIS .Nm .Op Fl f Ar filename -.Op Fl qV +.Op Fl qUV .Op Ar from-unit to-unit .Sh OPTIONS The following options are available: @@ -18,6 +18,11 @@ Specify the name of the units data file to load. .It Fl q Suppress prompting of the user for units and the display of statistics about the number of units loaded. +.It Fl U +If the default unit file exists prints its location. If not, print +.Qo +Units data file not found +.Qc .It Fl V Print the version number, usage, and then exit. .It Ar from-unit to-unit diff --git a/usr.bin/units/units.c b/usr.bin/units/units.c index 0ec77f6..c065941 100644 --- a/usr.bin/units/units.c +++ b/usr.bin/units/units.c @@ -678,7 +678,7 @@ void usage(void) { fprintf(stderr, - "usage: units [-f unitsfile] [-q] [-v] [from-unit to-unit]\n"); + "usage: units [-f unitsfile] [-UVq] [from-unit to-unit]\n"); exit(3); } @@ -700,7 +700,7 @@ main(int argc, char **argv) quiet = false; readfile = false; - while ((optchar = getopt(argc, argv, "Vqf:")) != -1) { + while ((optchar = getopt(argc, argv, "UVqf:")) != -1) { switch (optchar) { case 'f': readfile = true; @@ -712,6 +712,13 @@ main(int argc, char **argv) case 'q': quiet = true; break; + case 'U': + if (access(UNITSFILE, F_OK) == 0) + printf("%s\n", UNITSFILE); + else + printf("Units data file not found"); + exit(0); + break; case 'V': fprintf(stderr, "FreeBSD units\n"); usage(); |