sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit d221e5ea5b859df9805e14aaf99c644750c6da6a
parent 159cc298c4156a644d7b7a8bf9f06415943fab78
Author: sin <sin@2f30.org>
Date:   Thu, 20 Nov 2014 23:09:14 +0000

Print header in tail(1)

Diffstat:
Mtail.c | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tail.c b/tail.c @@ -24,6 +24,7 @@ main(int argc, char *argv[]) void (*tail)(FILE *, const char *, long) = taketail; char *lines; int ret = 0; + int newline, many; ARGBEGIN { case 'n': @@ -41,12 +42,17 @@ main(int argc, char *argv[]) if (argc == 0) { tail(stdin, "<stdin>", n); } else { - for (; argc > 0; argc--, argv++) { + many = argc > 1; + for (newline = 0; argc > 0; argc--, argv++) { if (!(fp = fopen(argv[0], "r"))) { weprintf("fopen %s:", argv[0]); ret = 1; continue; } + if (many) + printf("%s==> %s <==\n", + newline ? "\n" : "", argv[0]); + newline = 1; tail(fp, argv[0], n); fclose(fp); }