Sunday, August 02, 2020

Re: scp host:file* /tmp/nonexistent

On Sat, 1 Aug 2020, Christian Weisgerber wrote:

> Public service announcement: The original BSD repository can be
> browsed here (converted from SCCS):
> https://svnweb.freebsd.org/csrg/
>
> Wanna know what those hippies at Berkeley really did?
> You can look it up.

Thanks for the nice repo with the commentaries!

Here is the code for cp:

https://svnweb.freebsd.org/csrg/bin/cp/cp.c?revision=69112&view=markup
https://svnweb.freebsd.org/csrg/bin/cp/utils.c?revision=66606&view=markup

A challenge: where does the code distinguish src from src/ ?

Indeed it behaves like rsync, but we read in the source something
that seems to contradict it:

/*
* Cp has two distinct cases:
*
* cp [-R] source target
* cp [-R] source1 ... sourceN directory
*
* In both cases, source can be either a file or a directory.
*
* In (1), the target becomes a copy of the source. That is, if the
* source is a file, the target will be a file, and likewise for
* directories.
*
* In (2), the real target is not directory, but "directory/source".
*/

Was it a bug?

BTW, I do not remember this behaviour in SunOS, but also not in
FreeBSD when I used it many years ago, although it was there.

Rodrigo

No comments:

Post a Comment