sbase/cat.c
Connor Lane Smith bf9626d408 add tail
2011-05-26 16:18:42 -01:00

25 lines
531 B
C

/* See LICENSE file for copyright and license details. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "text.h"
#include "util.h"
int
main(int argc, char *argv[])
{
FILE *fp;
if(getopt(argc, argv, "") != -1)
exit(EXIT_FAILURE);
if(optind == argc)
concat(stdin, "<stdin>", stdout, "<stdout>");
else for(; optind < argc; optind++) {
if(!(fp = fopen(argv[optind], "r")))
eprintf("fopen %s:", argv[optind]);
concat(fp, argv[optind], stdout, "<stdout>");
fclose(fp);
}
return EXIT_SUCCESS;
}