wc: Report exit status properly

This commit is contained in:
sin 2015-02-06 19:11:33 +00:00
parent 3b4a366ffd
commit 0c8fe5d19b

4
wc.c
View File

@ -67,6 +67,7 @@ main(int argc, char *argv[])
{ {
FILE *fp; FILE *fp;
int i; int i;
int ret = 0;
ARGBEGIN { ARGBEGIN {
case 'c': case 'c':
@ -91,6 +92,7 @@ main(int argc, char *argv[])
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
if (!(fp = fopen(argv[i], "r"))) { if (!(fp = fopen(argv[i], "r"))) {
weprintf("fopen %s:", argv[i]); weprintf("fopen %s:", argv[i]);
ret = 1;
continue; continue;
} }
wc(fp, argv[i]); wc(fp, argv[i]);
@ -99,5 +101,5 @@ main(int argc, char *argv[])
if (argc > 1) if (argc > 1)
output("total", tc, tl, tw); output("total", tc, tl, tw);
} }
return 0; return ret;
} }