cp -R dir dir2
cp -R dir/ dir2
cp -R dir/* dir2
I was not aware that the second and third comands are equivalent and I find it annoying. Is it new behaviour?
cp -R dir dir2
cp -R dir/ dir2
cp -R dir/* dir2
rsync
also uses this same behavior.What do you think is 'normal'? I consider the behavior on FreeBSD to be normal and everything else strange.I just tested cp -R in OpenBSD and it has the normal behaviour.
Probably also because there are a few different "strains" of Unix. There's the obvious BSD one we all know and love. Another big one was System V. Plus a bunch of variants that used a combination of BSD and System V. And then there's GNU; the acronym should tell you enough; GNU's Not Unix.it seems there is no true Unix-like behavior for cp in recursive form
What do you think is 'normal'? I consider the behavior on FreeBSD to be normal and everything else strange.
cp -R dir/ dir2
is: for doing cp -R dir dir2
I normally use shell completion, but then I must delete the slash, otherwise dir2 gets trashed. cp -R dir/ dir2
is not necessary, one just does cp -R dir/* dir2
and so is better: one explicitly writes what one wants.dir and dir/ represent the same directory and should be treated indifferently.
FreeBSDs cp -R dir/ dir2 is not necessary, one just does cp -R dir/* dir2 and so is better: one explicitly writes what one wants.
cp -R dir/ dir2
.Perhaps one day FreeBSD will be like a linux distribution.
mv /a/b/ foo
mv /a/b/ /a
In this case no idea. I must try. In one system and the other.
Is /a/b/ treated exactly as it were /c/d/e? Or as /c/d/e/?
/a/b/
, if b were a symlink, would do a wildcard move/copy of the files to where b points to. I now understand your frustration because I see a tiny inconsistency, so I don't know why the design decision to do /a/b/
as /a/b/*
if b is a directory. Hopefully a FreeBSD veteran in the community could shed some light here.When in doubt, check the source. You will notice the entire changelog from the last 25 years fits on one page.but I do not think that FreeBSDs cp -R behaviour is original BSD.
This is that source.Perhaps one has to compare the source of 5.3 and 5.4, or just install an old version.
-R If source_file designates a directory, cp copies the directory and
the entire subtree connected at that point. If the source_file
ends in a /, the contents of the directory are copied rather than
the directory itself. This option also causes symbolic links to be
copied, rather than indirected through, and for cp to create spe-
cial files rather than copying them as normal files. Created di-
rectories have the same mode as the corresponding source directory,
unmodified by the process' umask.