[hackers] [sbase] Support tail-ing multiple files || sin
commit cfe5e9ef3a589583936de6f59fa38f61ed336c5c
Author: sin <sin_AT_2f30.org>
Date: Tue Nov 12 10:45:18 2013 +0000
Support tail-ing multiple files
diff --git a/tail.c b/tail.c
index 9c241db..b01b0e8 100644
--- a/tail.c
+++ b/tail.c
_AT_@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
_AT_@ -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
", argv[0],
+ strerror(errno));
+ continue;
+ }
+ tail(fp, argv[0], n);
+ fclose(fp);
+ }
+ }
return EXIT_SUCCESS;
}
Received on Tue Nov 12 2013 - 11:47:27 CET
This archive was generated by hypermail 2.3.0
: Tue Nov 12 2013 - 11:48:20 CET