sbase

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

commit cfe5e9ef3a589583936de6f59fa38f61ed336c5c
parent d9abff1e84d0c1ea41cfa2305502cb3d0a76ba34
Author: sin <sin@2f30.org>
Date:   Tue, 12 Nov 2013 10:45:18 +0000

Support tail-ing multiple files

Diffstat:
tail.c | 19++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/tail.c b/tail.c @@ -1,4 +1,5 @@ /* See LICENSE file for copyright and license details. */ +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -38,13 +39,17 @@ main(int argc, char *argv[]) } ARGEND; if(argc == 0) { tail(stdin, "<stdin>", n); - } else if(argc == 1) { - if(!(fp = fopen(argv[0], "r"))) - eprintf("fopen %s:", argv[0]); - tail(fp, argv[0], n); - fclose(fp); - } else - usage(); + } else { + for (; argc > 0; argc--, argv++) { + if(!(fp = fopen(argv[0], "r"))) { + fprintf(stderr, "fopen %s: %s\n", argv[0], + strerror(errno)); + continue; + } + tail(fp, argv[0], n); + fclose(fp); + } + } return EXIT_SUCCESS; }