[hackers] [sbase] Print header in tail(1) || sin
commit d221e5ea5b859df9805e14aaf99c644750c6da6a
Author: sin <sin_AT_2f30.org>
Date: Thu Nov 20 23:09:14 2014 +0000
Print header in tail(1)
diff --git a/tail.c b/tail.c
index b3a8b30..c2bc6eb 100644
--- a/tail.c
+++ b/tail.c
_AT_@ -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':
_AT_@ -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);
}
Received on Fri Nov 21 2014 - 00:09:47 CET
This archive was generated by hypermail 2.3.0
: Fri Nov 21 2014 - 00:12:43 CET