Module Name:    src
Committed By:   maya
Date:           Sun Oct  1 20:49:25 UTC 2017

Modified Files:
        src/distrib/sets/lists/base: mi
        src/distrib/sets/lists/man: mi
        src/usr.bin/tail: Makefile tail.1 tail.c
Added Files:
        src/usr.bin/tail: tac.1

Log Message:
Add arguments to tail:
  -q: suppress filename headers when multiple files are used
  -v: print filename headers even when only one file is used

head already supports the same arguments, which originated in GNU head.
GNU tail also has the same flags.

Add tac, a hard link to 'tail -rq'.
Prints a file in reverse line order.

Similar to GNU tac, but lacking any options.

Add accompanying documentation.


To generate a diff of this commit:
cvs rdiff -u -r1.1161 -r1.1162 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.1561 -r1.1562 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/tail/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/tail/tac.1
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/tail/tail.1 src/usr.bin/tail/tail.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/base/mi
diff -u src/distrib/sets/lists/base/mi:1.1161 src/distrib/sets/lists/base/mi:1.1162
--- src/distrib/sets/lists/base/mi:1.1161	Sun Sep 17 00:00:39 2017
+++ src/distrib/sets/lists/base/mi	Sun Oct  1 20:49:25 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1161 2017/09/17 00:00:39 sevan Exp $
+# $NetBSD: mi,v 1.1162 2017/10/01 20:49:25 maya Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -940,6 +940,7 @@
 ./usr/bin/sysstat				base-util-bin
 ./usr/bin/systat				base-util-bin
 ./usr/bin/tabs					base-util-bin
+./usr/bin/tac					base-util-bin
 ./usr/bin/tail					base-util-bin
 ./usr/bin/talk					base-netutil-bin
 ./usr/bin/tar					base-util-bin

Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1561 src/distrib/sets/lists/man/mi:1.1562
--- src/distrib/sets/lists/man/mi:1.1561	Sat Sep 30 12:27:26 2017
+++ src/distrib/sets/lists/man/mi	Sun Oct  1 20:49:25 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1561 2017/09/30 12:27:26 sevan Exp $
+# $NetBSD: mi,v 1.1562 2017/10/01 20:49:25 maya Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -555,6 +555,7 @@
 ./usr/share/man/cat1/systat.0			man-util-catman		.cat
 ./usr/share/man/cat1/systrace.0			man-obsolete		obsolete
 ./usr/share/man/cat1/tabs.0			man-util-catman		.cat
+./usr/share/man/cat1/tac.0			man-util-catman		.cat
 ./usr/share/man/cat1/tail.0			man-util-catman		.cat
 ./usr/share/man/cat1/talk.0			man-netutil-catman	.cat
 ./usr/share/man/cat1/tar.0			man-util-catman		.cat
@@ -3732,6 +3733,7 @@
 ./usr/share/man/html1/sysstat.html		man-util-htmlman	html
 ./usr/share/man/html1/systat.html		man-util-htmlman	html
 ./usr/share/man/html1/tabs.html			man-util-htmlman	html
+./usr/share/man/html1/tac.html			man-util-htmlman	html
 ./usr/share/man/html1/tail.html			man-util-htmlman	html
 ./usr/share/man/html1/talk.html			man-netutil-htmlman	html
 ./usr/share/man/html1/tar.html			man-util-htmlman	html
@@ -6563,6 +6565,7 @@
 ./usr/share/man/man1/systat.1			man-util-man		.man
 ./usr/share/man/man1/systrace.1			man-obsolete		obsolete
 ./usr/share/man/man1/tabs.1			man-util-man		.man
+./usr/share/man/man1/tac.1			man-util-man		.man
 ./usr/share/man/man1/tail.1			man-util-man		.man
 ./usr/share/man/man1/talk.1			man-netutil-man		.man
 ./usr/share/man/man1/tar.1			man-util-man		.man

Index: src/usr.bin/tail/Makefile
diff -u src/usr.bin/tail/Makefile:1.3 src/usr.bin/tail/Makefile:1.4
--- src/usr.bin/tail/Makefile:1.3	Wed Nov 23 07:41:55 1994
+++ src/usr.bin/tail/Makefile	Sun Oct  1 20:49:24 2017
@@ -1,7 +1,11 @@
-#	$NetBSD: Makefile,v 1.3 1994/11/23 07:41:55 jtc Exp $
+#	$NetBSD: Makefile,v 1.4 2017/10/01 20:49:24 maya Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 PROG=	tail
 SRCS=	forward.c misc.c read.c reverse.c tail.c
 
+LINKS=	${BINDIR}/tail ${BINDIR}/tac
+
+MAN=	tail.1 tac.1
+
 .include <bsd.prog.mk>

Index: src/usr.bin/tail/tail.1
diff -u src/usr.bin/tail/tail.1:1.17 src/usr.bin/tail/tail.1:1.18
--- src/usr.bin/tail/tail.1:1.17	Tue Jul  4 07:04:50 2017
+++ src/usr.bin/tail/tail.1	Sun Oct  1 20:49:24 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tail.1,v 1.17 2017/07/04 07:04:50 wiz Exp $
+.\"	$NetBSD: tail.1,v 1.18 2017/10/01 20:49:24 maya Exp $
 .\"
 .\" Copyright (c) 1980, 1990, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"	@(#)tail.1	8.1 (Berkeley) 6/6/93
 .\"
-.Dd June 15, 2014
+.Dd October 1, 2017
 .Dt TAIL 1
 .Os
 .Sh NAME
@@ -43,7 +43,7 @@
 .Oo
 .Fl f |
 .Fl F |
-.Fl r
+.Fl rqv
 .Oc
 .Oo
 .Fl b Ar number |
@@ -133,12 +133,17 @@ The default for the
 option is to display all of the input.
 .El
 .Pp
-If more than a single file is specified, each file is preceded by a
+If more than a single file is specified, or the
+.Fl v
+option is used, each file is preceded by a
 header consisting of the string
 .Dq ==> XXX \*[Le]=
 where
 .Dq XXX
 is the name of the file.
+The
+.Fl q
+flag disables the printing of the header in all cases.
 .Sh EXIT STATUS
 .Ex -std tail
 .Sh SEE ALSO
Index: src/usr.bin/tail/tail.c
diff -u src/usr.bin/tail/tail.c:1.17 src/usr.bin/tail/tail.c:1.18
--- src/usr.bin/tail/tail.c:1.17	Thu Jan 31 23:09:06 2013
+++ src/usr.bin/tail/tail.c	Sun Oct  1 20:49:24 2017
@@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)tail.c	8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: tail.c,v 1.17 2013/01/31 23:09:06 wiz Exp $");
+__RCSID("$NetBSD: tail.c,v 1.18 2017/10/01 20:49:24 maya Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -67,6 +67,8 @@ main(int argc, char *argv[])
 	enum STYLE style;
 	int ch, first;
 	char *p;
+	int qflag = 0;
+	int vflag = 0;
 
 	setprogname(argv[0]);
 	off = 0;
@@ -105,32 +107,48 @@ main(int argc, char *argv[])
 
 	obsolete(argv);
 	style = NOTSET;
-	while ((ch = getopt(argc, argv, "Fb:c:fn:r")) != -1)
-		switch(ch) {
-		case 'F':
-			fflag = 2;
-			break;
-		case 'b':
-			ARG(512, FBYTES, RBYTES);
-			break;
-		case 'c':
-			ARG(1, FBYTES, RBYTES);
-			break;
-		case 'f':
-			fflag = 1;
-			break;
-		case 'n':
-			ARG(1, FLINES, RLINES);
-			break;
-		case 'r':
-			rflag = 1;
-			break;
-		case '?':
-		default:
-			usage();
-		}
-	argc -= optind;
-	argv += optind;
+	if (strcmp(getprogname(), "tac") == 0) {
+		qflag = 1;
+		vflag = 0;
+		rflag = 1;
+		argc -= 1;
+		argv += 1;
+	} else { /* tail */
+		while ((ch = getopt(argc, argv, "Fb:c:fn:rqv")) != -1)
+			switch(ch) {
+			case 'F':
+				fflag = 2;
+				break;
+			case 'b':
+				ARG(512, FBYTES, RBYTES);
+				break;
+			case 'c':
+				ARG(1, FBYTES, RBYTES);
+				break;
+			case 'f':
+				fflag = 1;
+				break;
+			case 'n':
+				ARG(1, FLINES, RLINES);
+				break;
+			case 'r':
+				rflag = 1;
+				break;
+			case 'q':
+				qflag = 1;
+				vflag = 0;
+				break;
+			case 'v':
+				qflag = 0;
+				vflag = 1;
+				break;
+			case '?':
+			default:
+				usage();
+			}
+		argc -= optind;
+		argv += optind;
+	}
 
 	if (fflag && argc > 1)
 		xerrx(1,
@@ -169,7 +187,7 @@ main(int argc, char *argv[])
 				ierr();
 				continue;
 			}
-			if (argc > 1) {
+			if (vflag || (qflag == 0 && argc > 1)) {
 				(void)printf("%s==> %s <==\n",
 				    first ? "" : "\n", fname);
 				first = 0;
@@ -299,7 +317,7 @@ static void
 usage(void)
 {
 	(void)fprintf(stderr,
-	    "Usage: %s [-f | -F | -r] [-b # | -c # | -n #] [file ...]\n",
+	    "Usage: %s [-f | -F | -rqv] [-b # | -c # | -n #] [file ...]\n",
 	    getprogname());
 	exit(1);
 }

Added files:

Index: src/usr.bin/tail/tac.1
diff -u /dev/null src/usr.bin/tail/tac.1:1.1
--- /dev/null	Sun Oct  1 20:49:25 2017
+++ src/usr.bin/tail/tac.1	Sun Oct  1 20:49:24 2017
@@ -0,0 +1,56 @@
+.\"	$NetBSD: tac.1,v 1.1 2017/10/01 20:49:24 maya Exp $
+.\"
+.\" Copyright (c) 2017 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Maya Rashish.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\"
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in
+.\"    the documentation and/or other materials provided with the
+.\"    distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd October 1, 2017
+.Dt TAC 1
+.Os
+.Sh NAME
+.Nm tac
+.Nd display file in reverse
+.Sh SYNOPSIS
+.Nm
+.Op Ar file ...
+.Sh DESCRIPTION
+.Nm
+.Pq cat backwards
+outputs the contents of each of each of the specified files,
+or of the standard input if no files are specified its standard input,
+in reverse line order to the standard output.
+.Sh EXIT STATUS
+.Ex -std tac
+.Sh COMPATIBILITY
+The
+.Nm
+utility doesn't support any of the options of GNU tac.
+.Sh SEE ALSO
+.Xr cat 1 ,
+.Xr tail 1

Reply via email to