svn commit: r332372 - head/usr.bin/tail
Kyle Evans
kevans at FreeBSD.org
Tue Apr 10 14:27:28 UTC 2018
Author: kevans
Date: Tue Apr 10 14:27:27 2018
New Revision: 332372
URL: https://svnweb.freebsd.org/changeset/base/332372
Log:
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.
Reviewed by: eadler (earlier version)
MFC after: 3 days
Modified:
head/usr.bin/tail/tail.1
head/usr.bin/tail/tail.c
Modified: head/usr.bin/tail/tail.1
==============================================================================
--- head/usr.bin/tail/tail.1 Tue Apr 10 14:13:35 2018 (r332371)
+++ head/usr.bin/tail/tail.1 Tue Apr 10 14:27:27 2018 (r332372)
@@ -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: head/usr.bin/tail/tail.c
==============================================================================
--- head/usr.bin/tail/tail.c Tue Apr 10 14:13:35 2018 (r332371)
+++ head/usr.bin/tail/tail.c Tue Apr 10 14:27:27 2018 (r332372)
@@ -51,6 +51,7 @@ static const char sccsid[] = "@(#)tail.c 8.1 (Berkeley
#include <err.h>
#include <errno.h>
+#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -65,6 +66,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[])
{
@@ -113,7 +122,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;
More information about the svn-src-all
mailing list