From owner-svn-src-stable-11@freebsd.org Fri Apr 13 17:57:01 2018 Return-Path: Delivered-To: svn-src-stable-11@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 68DDFF9B1AD; Fri, 13 Apr 2018 17:57:01 +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 1A39B7D524; Fri, 13 Apr 2018 17:57:01 +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 151051D089; Fri, 13 Apr 2018 17:57:01 +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 w3DHv0DU074549; Fri, 13 Apr 2018 17:57:00 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3DHv0Fs074545; Fri, 13 Apr 2018 17:57:00 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201804131757.w3DHv0Fs074545@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 13 Apr 2018 17:57:00 +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: r332482 - in stable/11/usr.bin: head tail X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11/usr.bin: head tail X-SVN-Commit-Revision: 332482 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-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Apr 2018 17:57:01 -0000 Author: kevans Date: Fri Apr 13 17:57:00 2018 New Revision: 332482 URL: https://svnweb.freebsd.org/changeset/base/332482 Log: MFC r332372-r332374: tail(1)/head(1) compatibility long options r332372: tail(1): Add some long options Add --blocks, --bytes, and --lines long options for -b, -c, and -n respectively. This improves tail(1)'s compatibility with its GNU counterpart in a straightforward way. r332373: tail(1): Address mandoc concern (space before punctuation after macro) r332374: head(1): Provide long options Provide long options --bytes and --lines to match -c and -n respectively. This improves head(1)'s compatibility with its GNU counterpart in a sensible way. Modified: stable/11/usr.bin/head/head.1 stable/11/usr.bin/head/head.c stable/11/usr.bin/tail/tail.1 stable/11/usr.bin/tail/tail.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/head/head.1 ============================================================================== --- stable/11/usr.bin/head/head.1 Fri Apr 13 17:45:54 2018 (r332481) +++ stable/11/usr.bin/head/head.1 Fri Apr 13 17:57:00 2018 (r332482) @@ -28,7 +28,7 @@ .\" @(#)head.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd March 16, 2013 +.Dd April 10, 2018 .Dt HEAD 1 .Os .Sh NAME @@ -48,6 +48,18 @@ files are specified. If .Ar count is omitted it defaults to 10. +.Pp +The following options are available: +.Bl -tag -width indent +.It Fl c Ar bytes , Fl -bytes Ns = Ns Ar bytes +Print +.Ar bytes +of each of the specified files. +.It Fl n Ar count , Fl -lines Ns = Ns Ar count +Print +.Ar count +lines of each of the specified files. +.El .Pp If more than a single file is specified, each file is preceded by a header consisting of the string Modified: stable/11/usr.bin/head/head.c ============================================================================== --- stable/11/usr.bin/head/head.c Fri Apr 13 17:45:54 2018 (r332481) +++ stable/11/usr.bin/head/head.c Fri Apr 13 17:57:00 2018 (r332482) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -62,6 +63,13 @@ static void head_bytes(FILE *, off_t); static void obsolete(char *[]); static void usage(void); +static const struct option long_opts[] = +{ + {"bytes", required_argument, NULL, 'c'}, + {"lines", required_argument, NULL, 'n'}, + {NULL, no_argument, NULL, 0} +}; + int main(int argc, char *argv[]) { @@ -72,7 +80,7 @@ main(int argc, char *argv[]) char *ep; obsolete(argv); - while ((ch = getopt(argc, argv, "n:c:")) != -1) + while ((ch = getopt_long(argc, argv, "+n:c:", long_opts, NULL)) != -1) switch(ch) { case 'c': bytecnt = strtoimax(optarg, &ep, 10); Modified: stable/11/usr.bin/tail/tail.1 ============================================================================== --- stable/11/usr.bin/tail/tail.1 Fri Apr 13 17:45:54 2018 (r332481) +++ stable/11/usr.bin/tail/tail.1 Fri Apr 13 17:57:00 2018 (r332482) @@ -31,7 +31,7 @@ .\" @(#)tail.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd March 16, 2013 +.Dd April 10, 2018 .Dt TAIL 1 .Os .Sh NAME @@ -73,11 +73,11 @@ or the last 10 lines of the input. .Pp The options are as follows: .Bl -tag -width indent -.It Fl b Ar number +.It Fl b Ar number , Fl -blocks Ns = Ns Ar number The location is .Ar number 512-byte blocks. -.It Fl c Ar number +.It Fl c Ar number , Fl -bytes Ns = Ns Ar number The location is .Ar number bytes. @@ -112,7 +112,7 @@ The option is the same as the .Fl f option if reading from standard input rather than a file. -.It Fl n Ar number +.It Fl n Ar number , Fl -lines Ns = Ns Ar number The location is .Ar number lines. Modified: stable/11/usr.bin/tail/tail.c ============================================================================== --- stable/11/usr.bin/tail/tail.c Fri Apr 13 17:45:54 2018 (r332481) +++ stable/11/usr.bin/tail/tail.c Fri Apr 13 17:57:00 2018 (r332482) @@ -49,6 +49,7 @@ static const char sccsid[] = "@(#)tail.c 8.1 (Berkeley #include #include +#include #include #include #include @@ -63,6 +64,14 @@ static file_info_t *files; static void obsolete(char **); static void usage(void); +static const struct option long_opts[] = +{ + {"blocks", required_argument, NULL, 'b'}, + {"bytes", required_argument, NULL, 'c'}, + {"lines", required_argument, NULL, 'n'}, + {NULL, no_argument, NULL, 0} +}; + int main(int argc, char *argv[]) { @@ -111,7 +120,8 @@ main(int argc, char *argv[]) obsolete(argv); style = NOTSET; off = 0; - while ((ch = getopt(argc, argv, "Fb:c:fn:qr")) != -1) + while ((ch = getopt_long(argc, argv, "+Fb:c:fn:qr", long_opts, NULL)) != + -1) switch(ch) { case 'F': /* -F is superset of (and implies) -f */ Fflag = fflag = 1;