From owner-svn-src-all@FreeBSD.ORG Fri Jul 4 22:19:22 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 53F4EB16; Fri, 4 Jul 2014 22:19:22 +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 411E0280D; Fri, 4 Jul 2014 22:19:22 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s64MJMUL014526; Fri, 4 Jul 2014 22:19:22 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s64MJLY4014524; Fri, 4 Jul 2014 22:19:21 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201407042219.s64MJLY4014524@svn.freebsd.org> From: Eitan Adler Date: Fri, 4 Jul 2014 22:19:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268271 - 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.18 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: Fri, 04 Jul 2014 22:19:22 -0000 Author: eadler Date: Fri Jul 4 22:19:21 2014 New Revision: 268271 URL: http://svnweb.freebsd.org/changeset/base/268271 Log: units(1): Add 'help' flag - Add support for --help for compatibility - Make usage() static 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 Fri Jul 4 21:34:48 2014 (r268270) +++ head/usr.bin/units/units.1 Fri Jul 4 22:19:21 2014 (r268271) @@ -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 Modified: head/usr.bin/units/units.c ============================================================================== --- head/usr.bin/units/units.c Fri Jul 4 21:34:48 2014 (r268270) +++ head/usr.bin/units/units.c Fri Jul 4 22:19:21 2014 (r268271) @@ -695,7 +695,7 @@ showanswer(struct unittype * have, struc } -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(); }