diff options
author | Tim J. Robbins <tjr@FreeBSD.org> | 2002-05-24 06:03:12 +0000 |
---|---|---|
committer | Tim J. Robbins <tjr@FreeBSD.org> | 2002-05-24 06:03:12 +0000 |
commit | a6ea32c3c5709e4b914a69fee3a7a8070ac14bc6 (patch) | |
tree | 09a83b33d2ca60d399a62239536484779cfaee70 /usr.bin/cut | |
parent | 885fbc97c14fbb5b5bdbbffe2f625b05ed9f0886 (diff) | |
download | src-a6ea32c3c5709e4b914a69fee3a7a8070ac14bc6.tar.gz src-a6ea32c3c5709e4b914a69fee3a7a8070ac14bc6.zip |
If processing of one file fails, try to process the remaining files and
exit non-zero instead of immediately exiting. The traditional BSD
behaviour is explicitly forbidden by P1003.2.
Notes
Notes:
svn path=/head/; revision=97218
Diffstat (limited to 'usr.bin/cut')
-rw-r--r-- | usr.bin/cut/cut.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/cut/cut.c b/usr.bin/cut/cut.c index bb7f51f4736e..93737fc667a9 100644 --- a/usr.bin/cut/cut.c +++ b/usr.bin/cut/cut.c @@ -71,7 +71,7 @@ main(argc, argv) { FILE *fp; void (*fcn) (FILE *, const char *) = NULL; - int ch; + int ch, rval; fcn = NULL; setlocale (LC_ALL, ""); @@ -115,16 +115,20 @@ main(argc, argv) } else if (!cflag || dflag || sflag) usage(); + rval = 0; if (*argv) for (; *argv; ++argv) { - if (!(fp = fopen(*argv, "r"))) - err(1, "%s", *argv); + if (!(fp = fopen(*argv, "r"))) { + warn("%s", *argv); + rval = 1; + continue; + } fcn(fp, *argv); (void)fclose(fp); } else fcn(stdin, "stdin"); - exit(0); + exit(rval); } size_t autostart, autostop, maxval; |