freebsd-nq/bin/cp
Kyle Evans 848263aad1 cp: fix some cases with infinite recursion
As noted in the PR, cp -R has some surprising behavior.  Typically, when
you `cp -R foo bar` where both foo and bar exist, foo is cleanly copied
to foo/bar.  When you `cp -R foo foo` (where foo clearly exists), cp(1)
goes a little off the rails as it creates foo/foo, then discovers that
and creates foo/foo/foo, so on and so forth, until it eventually fails.

POSIX doesn't seem to disallow this behavior, but it isn't very useful.
GNU cp(1) will detect the recursion and squash it, but emit a message in
the process that it has done so.

This change seemingly follows the GNU behavior, but it currently doesn't
warn about the situation -- the author feels that the final product is
about what one might expect from doing this and thus, doesn't need a
warning.  The author doesn't feel strongly about this.

PR:		235438
Reviewed by:	bapt
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D33944
2022-01-27 12:02:17 -06:00
..
tests cp: fix some cases with infinite recursion 2022-01-27 12:02:17 -06:00
cp.1 cp(1): Bugfixes for some issues reported by mandoc 2020-10-03 18:36:22 +00:00
cp.c cp: fix some cases with infinite recursion 2022-01-27 12:02:17 -06:00
extern.h
Makefile cp: add some basic tests 2020-09-23 03:01:14 +00:00
Makefile.depend
utils.c cp: fix indentation 2021-01-27 12:18:45 +01:00