-/* $OpenBSD: cp.c,v 1.48 2018/09/07 07:17:14 martijn Exp $ */
+/* $OpenBSD: cp.c,v 1.49 2018/09/07 07:44:15 martijn Exp $ */
/* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */
/*
!fts_dne(curr))) == 1)
rval = 1;
} else
- if ((cval = copy_file(curr, fts_dne(curr))) == 1)
+ if ((cval = copy_file(curr, !fts_dne(curr))) == 1)
rval = 1;
if (!cval && vflag)
(void)fprintf(stdout, "%s -> %s\n",
!fts_dne(curr))) == 1)
rval = 1;
} else
- if ((cval = copy_file(curr, fts_dne(curr))) == 1)
+ if ((cval = copy_file(curr, !fts_dne(curr))) == 1)
rval = 1;
if (!cval && vflag)
(void)fprintf(stdout, "%s -> %s\n",
warnc(EOPNOTSUPP, "%s", curr->fts_path);
break;
default:
- if ((cval = copy_file(curr, fts_dne(curr))) == 1)
+ if ((cval = copy_file(curr, !fts_dne(curr))) == 1)
rval = 1;
if (!cval && vflag)
(void)fprintf(stdout, "%s -> %s\n",
-/* $OpenBSD: utils.c,v 1.43 2018/09/07 07:17:14 martijn Exp $ */
+/* $OpenBSD: utils.c,v 1.44 2018/09/07 07:44:15 martijn Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
int copy_overwrite(void);
int
-copy_file(FTSENT *entp, int dne)
+copy_file(FTSENT *entp, int exists)
{
static char *buf;
static char *zeroes;
* In -f (force) mode, we always unlink the destination first
* if it exists. Note that -i and -f are mutually exclusive.
*/
- if (!dne && fflag)
+ if (exists && fflag)
(void)unlink(to.p_path);
/*
* other choice is 666 or'ed with the execute bits on the from file
* modified by the umask.)
*/
- if (!dne && !fflag) {
+ if (exists && !fflag) {
if (!copy_overwrite()) {
(void)close(from_fd);
return 2;
*/
#define RETAINBITS \
(S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
- if (!pflag && dne &&
+ if (!pflag && !exists &&
fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid) {
if (fstat(to_fd, &to_stat)) {
warn("%s", to.p_path);