← Back to context

Comment by 5555watch

1 day ago

On a somewhat related note, I really hate that in scp -r and -R mean entirely different things.

The worst is when things behave different when you give them `~/somedir` vs `~/somedir/`. I think it's rsync that does that

  • I really like this feature of rsync (trailing "/" means copy the directory contents to the dest, no trailing "/" means copy the directory itself). Other tools, like cp, don't have any way at all to say copy the directory contents to the dest, and for those tools the result depends on whether or not the destination already exists and is a directory (you might end up with a duplicate nested directory). Rsync produces the same result whether the destination already exists or not.

  • rsync, or at least the version I had would behave differently for 'rsync a b' vs 'rsync a/ b/', even though I added the slash for both sides.

  • And `cp`.

    • I remember that macOS/FreeBSD’s cp -R behaves differently depending on the trailing slash (it’s pointed out in the man page). But when I compared with GNU coreutils and busybox they did not, so it’s something to look out for.

How about port that is lowercase in ssh and uppercase in scp?

  • scp took -p from rcp/cp, where it already meant preserve times. So port got -P.