summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorwiz <wiz@NetBSD.org>2014-02-03 20:22:19 +0000
committerwiz <wiz@NetBSD.org>2014-02-03 20:22:19 +0000
commit59a7e9cc43328fa31381756cd38bd181da1d2a93 (patch)
tree83693a25bf69111ace59bfb93c081ce214a59b4e /usr.bin
parentefd0b7cea911d98031ddb3c7eaaf71692e7a8d3a (diff)
From Igor Sobrado in private email (based on his OpenBSD commit):
improve POSIX compliance by continuing to process the remaining file operands after not finding an input file. from the IEEE Std 1003.1-2008 (``POSIX.1'') rationale: "Unlike other utilities, some historical implementations of cut exit after not finding an input file, rather than continuing to process the remaining file operands. This behavior is prohibited by this volume of POSIX.1-2008, where only the exit status is affected by this problem." joint work with jmc@, who identified the compliance issue, and millert@ ok millert@, jmc@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cut/cut.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/usr.bin/cut/cut.c b/usr.bin/cut/cut.c
index 919d6358389..d84b46e4eba 100644
--- a/usr.bin/cut/cut.c
+++ b/usr.bin/cut/cut.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cut.c,v 1.28 2012/06/20 17:53:39 wiz Exp $ */
+/* $NetBSD: cut.c,v 1.29 2014/02/03 20:22:19 wiz Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\
#if 0
static char sccsid[] = "@(#)cut.c 8.3 (Berkeley) 5/4/95";
#endif
-__RCSID("$NetBSD: cut.c,v 1.28 2012/06/20 17:53:39 wiz Exp $");
+__RCSID("$NetBSD: cut.c,v 1.29 2014/02/03 20:22:19 wiz Exp $");
#endif /* not lint */
#include <ctype.h>
@@ -76,7 +76,7 @@ main(int argc, char *argv[])
{
FILE *fp;
void (*fcn)(FILE *, const char *);
- int ch;
+ int ch, rval;
fcn = NULL;
(void)setlocale(LC_ALL, "");
@@ -126,20 +126,24 @@ main(int argc, char *argv[])
else if (bflag && cflag)
usage();
+ rval = 0;
if (*argv)
for (; *argv; ++argv) {
if (strcmp(*argv, "-") == 0)
fcn(stdin, "stdin");
else {
- if ((fp = fopen(*argv, "r")) == NULL)
- err(1, "%s", *argv);
- fcn(fp, *argv);
- (void)fclose(fp);
+ if ((fp = fopen(*argv, "r"))) {
+ fcn(fp, *argv);
+ (void)fclose(fp);
+ } else {
+ rval = 1;
+ warn("%s", *argv);
+ }
}
}
else
fcn(stdin, "stdin");
- return 0;
+ return(rval);
}
static size_t autostart, autostop, maxval;