Re:The Unexpected Importance of the Trailing Slash
by lostmsu on Saturday April 09, 2022 @12:00PM
(#30969163)
I think that's a failure on SCP side. It should have never allowed scp -r dir target_dir with non-existent target_dir in the first place.
[ Parent
| on HN ]
Re:The Unexpected Importance of the Trailing Slash
by mhalle on Sunday April 10, 2022 @06:58AM
(#30976014)
I get what you are saying: cp/scp should have consistent behavior when the second arg is a directory. The "problem" operation you describe is analogous to copying plain files, though (copying contents to a new name).
I don't think having to create a target directory first is obvious, although neither is the fact that bare "cp" doesn't copy directories.
Finally, for remote copying it would be a nightmare for scp to require the destination directory to exist. To copy a directory tree to a remote server with a new name you'd need to either ssh a remote mkdir command, or add a flag to scp to specify the new name.