summaryrefslogtreecommitdiff
path: root/bin/cp/cp.c
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2018-09-07 13:46:34 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2018-09-07 13:46:34 +0000
commit91993b4cf89a0990a9932e95208c58e3acc6340d (patch)
tree74676b5d42bf4d420d5edacfc6080859790a4576 /bin/cp/cp.c
parent2911764c7cdae382a434e1d5c576ed53dc21c87c (diff)
Revert earlier revert.
It turned out the issue was a badly applied diff on stsp@'s machine. OK stsp@
Diffstat (limited to 'bin/cp/cp.c')
-rw-r--r--bin/cp/cp.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index 282defd171f..c2f947a721e 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cp.c,v 1.50 2018/09/07 11:01:22 stsp Exp $ */
+/* $OpenBSD: cp.c,v 1.51 2018/09/07 13:46:33 martijn Exp $ */
/* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */
/*
@@ -264,7 +264,7 @@ copy(char *argv[], enum op type, int fts_options)
struct stat to_stat;
FTS *ftsp;
FTSENT *curr;
- int base, nlen, rval;
+ int base, cval, nlen, rval;
char *p, *target_mid;
base = 0;
@@ -395,9 +395,9 @@ copy(char *argv[], enum op type, int fts_options)
switch (curr->fts_statp->st_mode & S_IFMT) {
case S_IFLNK:
- if (copy_link(curr, !fts_dne(curr)))
+ if ((cval = copy_link(curr, !fts_dne(curr))) == 1)
rval = 1;
- else if (vflag)
+ if (!cval && vflag)
(void)fprintf(stdout, "%s -> %s\n",
curr->fts_path, to.p_path);
break;
@@ -430,36 +430,40 @@ copy(char *argv[], enum op type, int fts_options)
case S_IFBLK:
case S_IFCHR:
if (Rflag) {
- if (copy_special(curr->fts_statp,
- !fts_dne(curr)))
+ if ((cval = copy_special(curr->fts_statp,
+ !fts_dne(curr))) == 1)
rval = 1;
} else
- if (copy_file(curr, fts_dne(curr)))
+ if ((cval = copy_file(curr, !fts_dne(curr))) == 1)
rval = 1;
- if (!rval && vflag)
+ if (!cval && vflag)
(void)fprintf(stdout, "%s -> %s\n",
curr->fts_path, to.p_path);
+ cval = 0;
break;
case S_IFIFO:
if (Rflag) {
- if (copy_fifo(curr->fts_statp, !fts_dne(curr)))
+ if ((cval = copy_fifo(curr->fts_statp,
+ !fts_dne(curr))) == 1)
rval = 1;
} else
- if (copy_file(curr, fts_dne(curr)))
+ if ((cval = copy_file(curr, !fts_dne(curr))) == 1)
rval = 1;
- if (!rval && vflag)
+ if (!cval && vflag)
(void)fprintf(stdout, "%s -> %s\n",
curr->fts_path, to.p_path);
+ cval = 0;
break;
case S_IFSOCK:
warnc(EOPNOTSUPP, "%s", curr->fts_path);
break;
default:
- if (copy_file(curr, fts_dne(curr)))
+ if ((cval = copy_file(curr, !fts_dne(curr))) == 1)
rval = 1;
- else if (vflag)
+ if (!cval && vflag)
(void)fprintf(stdout, "%s -> %s\n",
curr->fts_path, to.p_path);
+ cval = 0;
break;
}
}