From owner-svn-src-stable@freebsd.org Wed Jun 27 20:55:50 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB0801010B24; Wed, 27 Jun 2018 20:55:50 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6C1B072AAB; Wed, 27 Jun 2018 20:55:50 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4D03139B; Wed, 27 Jun 2018 20:55:50 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5RKto8T095265; Wed, 27 Jun 2018 20:55:50 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5RKtnIH095263; Wed, 27 Jun 2018 20:55:49 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201806272055.w5RKtnIH095263@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 27 Jun 2018 20:55:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335737 - stable/11/usr.bin/uniq X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/uniq X-SVN-Commit-Revision: 335737 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2018 20:55:51 -0000 Author: kevans Date: Wed Jun 27 20:55:49 2018 New Revision: 335737 URL: https://svnweb.freebsd.org/changeset/base/335737 Log: MFC r333156: uniq(1): Add some long options These match GNU uniq(1) where appropriate for compatibility's sake. While here, re-sort options alphabetically by the short-option. Modified: stable/11/usr.bin/uniq/uniq.1 stable/11/usr.bin/uniq/uniq.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/uniq/uniq.1 ============================================================================== --- stable/11/usr.bin/uniq/uniq.1 Wed Jun 27 20:54:12 2018 (r335736) +++ stable/11/usr.bin/uniq/uniq.1 Wed Jun 27 20:55:49 2018 (r335737) @@ -31,7 +31,7 @@ .\" From: @(#)uniq.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd May 15, 2017 +.Dd May 1, 2018 .Dt UNIQ 1 .Os .Sh NAME @@ -71,34 +71,34 @@ so it may be necessary to sort the files first. .Pp The following options are available: .Bl -tag -width Ds -.It Fl c +.It Fl c , Fl -count Precede each output line with the count of the number of times the line occurred in the input, followed by a single space. -.It Fl d +.It Fl d , Fl -repeated Only output lines that are repeated in the input. -.It Fl f Ar num +.It Fl f Ar num , Fl -skip-fields Ar num Ignore the first .Ar num fields in each input line when doing comparisons. A field is a string of non-blank characters separated from adjacent fields by blanks. Field numbers are one based, i.e., the first field is field one. -.It Fl s Ar chars +.It Fl i , Fl -ignore-case +Case insensitive comparison of lines. +.It Fl s Ar chars , Fl -skip-chars Ar chars Ignore the first .Ar chars characters in each input line when doing comparisons. If specified in conjunction with the -.Fl f +.Fl f , Fl -unique option, the first .Ar chars characters after the first .Ar num fields will be ignored. Character numbers are one based, i.e., the first character is character one. -.It Fl u +.It Fl u , Fl -unique Only output lines that are not repeated in the input. -.It Fl i -Case insensitive comparison of lines. .\".It Fl Ns Ar n .\"(Deprecated; replaced by .\".Fl f ) . Modified: stable/11/usr.bin/uniq/uniq.c ============================================================================== --- stable/11/usr.bin/uniq/uniq.c Wed Jun 27 20:54:12 2018 (r335736) +++ stable/11/usr.bin/uniq/uniq.c Wed Jun 27 20:55:49 2018 (r335737) @@ -49,6 +49,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -65,6 +66,17 @@ static const char rcsid[] = static int cflag, dflag, uflag, iflag; static int numchars, numfields, repeats; +static const struct option long_opts[] = +{ + {"count", no_argument, NULL, 'c'}, + {"repeated", no_argument, NULL, 'd'}, + {"skip-fields", required_argument, NULL, 'f'}, + {"ignore-case", no_argument, NULL, 'i'}, + {"skip-chars", required_argument, NULL, 's'}, + {"unique", no_argument, NULL, 'u'}, + {NULL, no_argument, NULL, 0} +}; + static FILE *file(const char *, const char *); static wchar_t *convert(const char *); static int inlcmp(const char *, const char *); @@ -98,7 +110,8 @@ main (int argc, char *argv[]) (void) setlocale(LC_ALL, ""); obsolete(argv); - while ((ch = getopt(argc, argv, "cdif:s:u")) != -1) + while ((ch = getopt_long(argc, argv, "+cdif:s:u", long_opts, + NULL)) != -1) switch (ch) { case 'c': cflag = 1;