When -R is not specified, fail to copy the contents of dangling symlinks
instead of making a copy of the link itself (SUSv3) Obtained from: NetBSD
This commit is contained in:
parent
560edda366
commit
f9dc2a8b93
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=98171
14
bin/cp/cp.c
14
bin/cp/cp.c
@ -167,7 +167,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
} else {
|
||||
fts_options &= ~FTS_PHYSICAL;
|
||||
fts_options |= FTS_LOGICAL;
|
||||
fts_options |= FTS_LOGICAL | FTS_COMFOLLOW;
|
||||
}
|
||||
|
||||
/* Save the target base in "to". */
|
||||
@ -397,8 +397,16 @@ copy(char *argv[], enum op type, int fts_options)
|
||||
|
||||
switch (curr->fts_statp->st_mode & S_IFMT) {
|
||||
case S_IFLNK:
|
||||
if (copy_link(curr, !dne))
|
||||
badcp = rval = 1;
|
||||
/* Catch special case of a non-dangling symlink */
|
||||
if ((fts_options & FTS_LOGICAL) ||
|
||||
((fts_options & FTS_COMFOLLOW) &&
|
||||
curr->fts_level == 0)) {
|
||||
if (copy_file(curr, dne))
|
||||
badcp = rval = 1;
|
||||
} else {
|
||||
if (copy_link(curr, !dne))
|
||||
badcp = rval = 1;
|
||||
}
|
||||
break;
|
||||
case S_IFDIR:
|
||||
if (!Rflag && !rflag) {
|
||||
|
Loading…
Reference in New Issue
Block a user