Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Apr 2014 16:55:10 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r264463 - head/usr.bin/units
Message-ID:  <201404141655.s3EGtAbM033038@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Mon Apr 14 16:55:09 2014
New Revision: 264463
URL: http://svnweb.freebsd.org/changeset/base/264463

Log:
  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.

Modified:
  head/usr.bin/units/units.1
  head/usr.bin/units/units.c

Modified: head/usr.bin/units/units.1
==============================================================================
--- head/usr.bin/units/units.1	Mon Apr 14 16:43:36 2014	(r264462)
+++ head/usr.bin/units/units.1	Mon Apr 14 16:55:09 2014	(r264463)
@@ -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 
 .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

Modified: head/usr.bin/units/units.c
==============================================================================
--- head/usr.bin/units/units.c	Mon Apr 14 16:43:36 2014	(r264462)
+++ head/usr.bin/units/units.c	Mon Apr 14 16:55:09 2014	(r264463)
@@ -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();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404141655.s3EGtAbM033038>