Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add arguments to tail:
details: https://anonhg.NetBSD.org/src/rev/2bacd2b276ca
branches: trunk
changeset: 826830:2bacd2b276ca
user: maya <maya%NetBSD.org@localhost>
date: Sun Oct 01 20:49:24 2017 +0000
description:
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.
diffstat:
distrib/sets/lists/base/mi | 3 +-
distrib/sets/lists/man/mi | 5 ++-
usr.bin/tail/Makefile | 6 +++-
usr.bin/tail/tac.1 | 56 +++++++++++++++++++++++++++++++++
usr.bin/tail/tail.1 | 13 +++++--
usr.bin/tail/tail.c | 76 ++++++++++++++++++++++++++++-----------------
6 files changed, 123 insertions(+), 36 deletions(-)
diffs (286 lines):
diff -r 69cdaf552cb6 -r 2bacd2b276ca distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi Sun Oct 01 15:05:09 2017 +0000
+++ b/distrib/sets/lists/base/mi Sun Oct 01 20:49:24 2017 +0000
@@ -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
diff -r 69cdaf552cb6 -r 2bacd2b276ca distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Sun Oct 01 15:05:09 2017 +0000
+++ b/distrib/sets/lists/man/mi Sun Oct 01 20:49:24 2017 +0000
@@ -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
diff -r 69cdaf552cb6 -r 2bacd2b276ca usr.bin/tail/Makefile
--- a/usr.bin/tail/Makefile Sun Oct 01 15:05:09 2017 +0000
+++ b/usr.bin/tail/Makefile Sun Oct 01 20:49:24 2017 +0000
@@ -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>
diff -r 69cdaf552cb6 -r 2bacd2b276ca usr.bin/tail/tac.1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/tail/tac.1 Sun Oct 01 20:49:24 2017 +0000
@@ -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
diff -r 69cdaf552cb6 -r 2bacd2b276ca usr.bin/tail/tail.1
--- a/usr.bin/tail/tail.1 Sun Oct 01 15:05:09 2017 +0000
+++ b/usr.bin/tail/tail.1 Sun Oct 01 20:49:24 2017 +0000
@@ -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 @@
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
diff -r 69cdaf552cb6 -r 2bacd2b276ca usr.bin/tail/tail.c
--- a/usr.bin/tail/tail.c Sun Oct 01 15:05:09 2017 +0000
+++ b/usr.bin/tail/tail.c Sun Oct 01 20:49:24 2017 +0000
@@ -40,7 +40,7 @@
#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 @@
enum STYLE style;
int ch, first;
char *p;
+ int qflag = 0;
+ int vflag = 0;
setprogname(argv[0]);
off = 0;
@@ -105,32 +107,48 @@
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 @@
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 @@
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);
}
Home |
Main Index |
Thread Index |
Old Index