Why does one of there work and the other doesn't

Mark Eichin eichin at thok.org
Mon Dec 3 13:31:25 EST 2001

> Perhaps a trailing "/" instead of training "/." is supposed to work.  I do
> not remember why I didn't start using it, but I am sure I would have tried

Quite possibly because you've been bitten by class cp/rcp; cp is not
idempotent, in that if you "cp -r foo bar" where foo is a dir and bar
doesn't exist, you end up with a bar that has the contents of foo
(ie. foo/zot -> bar/zot) and if you do it twice, cp sees that bar is a
dir and inserts it instead (so foo->bar/foo, foo/zot->bar/foo/zot.)
TO make it worse, on BSD-ish systems, traditionally adding a trailing
slash makes it treat bar as a directory (bar/ == bar/"" == bar/.), but
under sysv-ish systems it doesn't change the interpretation (bar/ ==
bar, even if bar doesn't exist.)

Partially *because* of this horror, rsync is (and is documented to be)
consistent, and to have an explicit interpretation of trailing slash
(that is consistent with bar/ == bar/. as far as destinations are
concerned)  and is independent of the existence of the destination, so
you can expect it to do the same thing when run twice.  This is one
reason i'll often run rsync -a on local files rather than cp -r...

More information about the rsync mailing list