Support tail-ing multiple files
This commit is contained in:
parent
d9abff1e84
commit
cfe5e9ef3a
19
tail.c
19
tail.c
|
@ -1,4 +1,5 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -38,13 +39,17 @@ main(int argc, char *argv[])
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
if(argc == 0) {
|
if(argc == 0) {
|
||||||
tail(stdin, "<stdin>", n);
|
tail(stdin, "<stdin>", n);
|
||||||
} else if(argc == 1) {
|
} else {
|
||||||
if(!(fp = fopen(argv[0], "r")))
|
for (; argc > 0; argc--, argv++) {
|
||||||
eprintf("fopen %s:", argv[0]);
|
if(!(fp = fopen(argv[0], "r"))) {
|
||||||
tail(fp, argv[0], n);
|
fprintf(stderr, "fopen %s: %s\n", argv[0],
|
||||||
fclose(fp);
|
strerror(errno));
|
||||||
} else
|
continue;
|
||||||
usage();
|
}
|
||||||
|
tail(fp, argv[0], n);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user