Don't exit on the first file that can't be opened for head and fold

This commit is contained in:
sin
2013-11-12 10:44:37 +00:00
parent 7add068ade
commit d9abff1e84
2 changed files with 13 additions and 4 deletions

8
head.c
View File

@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -33,8 +34,11 @@ main(int argc, char *argv[])
if(argc == 0) {
head(stdin, "<stdin>", n);
} else for(; argc > 0; argc--, argv++) {
if(!(fp = fopen(argv[0], "r")))
eprintf("fopen %s:", argv[0]);
if(!(fp = fopen(argv[0], "r"))) {
fprintf(stderr, "fopen %s: %s\n", argv[0],
strerror(errno));
continue;
}
head(fp, argv[0], n);
fclose(fp);
}