1
0
mirror of git://git.suckless.org/sbase synced 2024-12-23 15:34:38 +00:00
sbase/cat.c

25 lines
531 B
C
Raw Normal View History

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