summaryrefslogtreecommitdiffstats
path: root/usr.bin/paste
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-05-24 06:17:29 +0000
committertjr <tjr@FreeBSD.org>2002-05-24 06:17:29 +0000
commite1f16de894e106961e4e034a68c16281a24b837f (patch)
tree8212e66a3e149a2aebbb79de3b1d1b28e11e3a3e /usr.bin/paste
parent962a6ce9c88faeeb0c0de185af1e19693a7d6a8b (diff)
downloadFreeBSD-src-e1f16de894e106961e4e034a68c16281a24b837f.zip
FreeBSD-src-e1f16de894e106961e4e034a68c16281a24b837f.tar.gz
Exit with non-zero status if any files specified could not be opened
when -s option is given (SUSv3).
Diffstat (limited to 'usr.bin/paste')
-rw-r--r--usr.bin/paste/paste.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/usr.bin/paste/paste.c b/usr.bin/paste/paste.c
index ea75288..730ae67 100644
--- a/usr.bin/paste/paste.c
+++ b/usr.bin/paste/paste.c
@@ -62,8 +62,8 @@ __FBSDID("$FreeBSD$");
char *delim;
int delimcnt;
-void parallel(char **);
-void sequential(char **);
+int parallel(char **);
+int sequential(char **);
int tr(char *);
static void usage(void);
@@ -72,7 +72,7 @@ char tab[] = "\t";
int
main(int argc, char *argv[])
{
- int ch, seq;
+ int ch, rval, seq;
seq = 0;
while ((ch = getopt(argc, argv, "d:s")) != -1)
@@ -98,10 +98,10 @@ main(int argc, char *argv[])
}
if (seq)
- sequential(argv);
+ rval = sequential(argv);
else
- parallel(argv);
- exit(0);
+ rval = parallel(argv);
+ exit(rval);
}
typedef struct _list {
@@ -111,7 +111,7 @@ typedef struct _list {
char *name;
} LIST;
-void
+int
parallel(char **argv)
{
LIST *lp;
@@ -175,21 +175,25 @@ parallel(char **argv)
if (output)
putchar('\n');
}
+
+ return (0);
}
-void
+int
sequential(char **argv)
{
FILE *fp;
- int cnt;
+ int cnt, failed;
char ch, *p, *dp;
char buf[_POSIX2_LINE_MAX + 1];
+ failed = 0;
for (; (p = *argv); ++argv) {
if (p[0] == '-' && !p[1])
fp = stdin;
else if (!(fp = fopen(p, "r"))) {
warn("%s", p);
+ failed = 1;
continue;
}
if (fgets(buf, sizeof(buf), fp)) {
@@ -212,6 +216,8 @@ sequential(char **argv)
if (fp != stdin)
(void)fclose(fp);
}
+
+ return (failed != 0);
}
int
OpenPOWER on IntegriCloud