summaryrefslogtreecommitdiff
path: root/bin/cp
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2018-09-07 07:11:17 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2018-09-07 07:11:17 +0000
commit9ac8109112a8f96912b8d8f782569ec0e2ad1bac (patch)
treed79e21ccbfd088831c25971da60e50cc8619a14a /bin/cp
parent416fa5a358c9258aa2a8ae143345caaecbf514a8 (diff)
The combination of -v and -i and the deny of a copy would cause the copy
still to be printed. This fixes that edge-case. OK stsp@
Diffstat (limited to 'bin/cp')
-rw-r--r--bin/cp/cp.c19
-rw-r--r--bin/cp/utils.c4
2 files changed, 13 insertions, 10 deletions
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index 532edbb5ba7..6e558e99588 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cp.c,v 1.46 2017/06/27 21:49:47 tedu Exp $ */
+/* $OpenBSD: cp.c,v 1.47 2018/09/07 07:11:16 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;
@@ -434,32 +434,35 @@ copy(char *argv[], enum op type, int fts_options)
!fts_dne(curr)))
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)))
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;
}
}
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index c9d71986842..5d4db72ba10 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utils.c,v 1.40 2017/06/27 21:43:46 tedu Exp $ */
+/* $OpenBSD: utils.c,v 1.41 2018/09/07 07:11:16 martijn Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
@@ -99,7 +99,7 @@ copy_file(FTSENT *entp, int dne)
ch = getchar();
if (checkch != 'y' && checkch != 'Y') {
(void)close(from_fd);
- return (0);
+ return (2);
}
}
to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0);