|
|
Log in / Subscribe / Register

OpenSSH 8.0 released

OpenSSH 8.0 released

Posted Apr 20, 2019 22:11 UTC (Sat) by karkhaz (subscriber, #99844)
In reply to: OpenSSH 8.0 released by dw
Parent article: OpenSSH 8.0 released

So first of all, I don't think a slash on the destination ever matters.

A slash on the source directory does change rsync's behaviour, but that has nothing to do with whether the destination exists. The behaviours are orthogonal, here is a matrix:

when dst doesn't exist
rsync -a src/ dst --> creates dst, copies contents of src into dst
rsync -a src dst --> creates dst, copies src into dst

when dst exists
rsync -a src/ dst --> copies contents of src into dst
rsync -a src dst --> copies src into dst

I do remember being surprised by this when I first used rsync, but the man page is fairly clear about it; I'm curious to hear if what behaviour you might find less surprising, while retaining the ability to copy either a directory or its contents (without using shell wildcards or the like)?


to post comments

OpenSSH 8.0 released

Posted Apr 22, 2019 9:12 UTC (Mon) by oldtomas (guest, #72579) [Link]

Quoth the man page:

"A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning 'copy the contents of this directory' as opposed to 'copy the directory by name', but in both cases the attributes of the containing directory are transferred to the containing directory on the destination"

(And for the reverse: just searching for "trailing" or "trailing slash" clears that part up pretty quickly).

Rsync's man page may be daunting, but it is extremely well written.

"If all else fails, read the instructions"

rsync mnemonic

Posted Apr 26, 2019 21:43 UTC (Fri) by naptastic (guest, #60139) [Link] (1 responses)

The choice seemed arbitrary to me until I came up with a mnemonic for it: Trailing slash means "the contents of the directory," and no trailing slash means "the directory as a single thing." Somehow my brain also maps that to pointers versus values:
rsync(src, dest);  /* one item, named 'src', will be created in dest */
rsync(*src, dest); /* everything under 'src' will be created in dest */
I don't know if that helps or even makes sense to anyone else.

rsync mnemonic

Posted Apr 26, 2019 23:49 UTC (Fri) by karkhaz (subscriber, #99844) [Link]

That's a beautiful analogy :-)


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds