Avoid errors like "cp: /foo/bar/directory" exists if cp(1) is used to

copy multiple directories and the first one doesn't exist in the
target directiry but another one (e.g. the second) does.
This commit is contained in:
tron 2006-08-15 13:06:02 +00:00
parent 0da8c70aed
commit af4d285682

View File

@ -1,4 +1,4 @@
/* $NetBSD: cp.c,v 1.44 2006/07/16 16:22:24 jschauma Exp $ */
/* $NetBSD: cp.c,v 1.45 2006/08/15 13:06:02 tron Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
@ -43,7 +43,7 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)cp.c 8.5 (Berkeley) 4/29/95";
#else
__RCSID("$NetBSD: cp.c,v 1.44 2006/07/16 16:22:24 jschauma Exp $");
__RCSID("$NetBSD: cp.c,v 1.45 2006/08/15 13:06:02 tron Exp $");
#endif
#endif /* not lint */
@ -290,13 +290,13 @@ copy(char *argv[], enum op type, int fts_options)
size_t nlen;
char *p, *target_mid;
dne = 0;
base = 0; /* XXX gcc -Wuninitialized (see comment below) */
if ((ftsp = fts_open(argv, fts_options, mastercmp)) == NULL)
err(EXIT_FAILURE, "%s", argv[0]);
/* NOTREACHED */
for (rval = 0; (curr = fts_read(ftsp)) != NULL;) {
dne = 0;
switch (curr->fts_info) {
case FTS_NS:
case FTS_DNR: