From owner-svn-src-all@FreeBSD.ORG Mon Apr 14 16:55:10 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8BB89214; Mon, 14 Apr 2014 16:55:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5EA5A104A; Mon, 14 Apr 2014 16:55:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3EGtAcK033040; Mon, 14 Apr 2014 16:55:10 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3EGtAbM033038; Mon, 14 Apr 2014 16:55:10 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201404141655.s3EGtAbM033038@svn.freebsd.org> From: Eitan Adler Date: Mon, 14 Apr 2014 16:55:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264463 - head/usr.bin/units X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Apr 2014 16:55:10 -0000 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();