From owner-svn-src-head@FreeBSD.ORG Fri Jul 4 04:47:30 2014 Return-Path: Delivered-To: svn-src-head@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 2E7403D3; Fri, 4 Jul 2014 04:47:30 +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 023CF2C50; Fri, 4 Jul 2014 04:47:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s644lT5l006719; Fri, 4 Jul 2014 04:47:29 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s644lT4O006716; Fri, 4 Jul 2014 04:47:29 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201407040447.s644lT4O006716@svn.freebsd.org> From: Eitan Adler Date: Fri, 4 Jul 2014 04:47:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268242 - head/usr.bin/look X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jul 2014 04:47:30 -0000 Author: eadler Date: Fri Jul 4 04:47:29 2014 New Revision: 268242 URL: http://svnweb.freebsd.org/changeset/base/268242 Log: look: implement long options gentoo has "util-linux 2.24.1" with long options. Other distributions have similar. usage() is intentionally unchanged to keep it short and sweet Reviewed by: jmg Discussed with: adrian, jilles Modified: head/usr.bin/look/look.1 head/usr.bin/look/look.c Modified: head/usr.bin/look/look.1 ============================================================================== --- head/usr.bin/look/look.1 Thu Jul 3 23:12:43 2014 (r268241) +++ head/usr.bin/look/look.1 Fri Jul 4 04:47:29 2014 (r268242) @@ -63,12 +63,12 @@ alphabetic characters is ignored. .Pp The following options are available: .Bl -tag -width indent -.It Fl d +.It Fl d , -alphanum Dictionary character set and order, i.e., only alphanumeric characters are compared. -.It Fl f +.It Fl f , -ignore-case Ignore the case of alphabetic characters. -.It Fl t +.It Fl t , -terminate Ar termchar Specify a string termination character, i.e., only the characters in .Ar string @@ -106,7 +106,9 @@ implementation. .Pp The .Fl a -flag is ignored for compability. +and +.Fl -alternative +flags are ignored for compability. .Sh SEE ALSO .Xr grep 1 , .Xr sort 1 Modified: head/usr.bin/look/look.c ============================================================================== --- head/usr.bin/look/look.c Thu Jul 3 23:12:43 2014 (r268241) +++ head/usr.bin/look/look.c Fri Jul 4 04:47:29 2014 (r268242) @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -88,6 +89,14 @@ static void print_from(wchar_t *, unsig static void usage(void); +static struct option longopts[] = { + { "alternative",no_argument, NULL, 'a' }, + { "alphanum", no_argument, NULL, 'd' }, + { "ignore-case",no_argument, NULL, 'i' }, + { "terminate", required_argument, NULL, 't'}, + { NULL, 0, NULL, 0 }, +}; + int main(int argc, char *argv[]) { @@ -102,7 +111,7 @@ main(int argc, char *argv[]) file = _path_words; termchar = L'\0'; - while ((ch = getopt(argc, argv, "adft:")) != -1) + while ((ch = getopt_long(argc, argv, "+adft:", longopts, NULL)) != -1) switch(ch) { case 'a': /* COMPATIBILITY */