6 ms·
If you use a trailing slash on the source it copies from the directory, if you omit the trailing slash it copies the directory itself. AFAIK this is pretty stan
by hilsdev 4mo ago
If you use a trailing slash on the source it copies from the directory, if you omit the trailing slash it copies the directory itself. AFAIK this is pretty standard across POSIX tools
- SoftTalker 4mo agoIt's not, for example cp -R doesn't change behavior on the basis of a trailing slash on directory names.
- m463 4mo agoI was implementing something recently and stumbled across that cp difference. ugh. the trailing slash is pretty convenient.
- fsckboy 4mo agothat's not a cp difference, cp is the granddaddy here I think trailing / could be a nice way to indicate some meaningful difference, but since autocomplete always sticks it in, just feels like a bad idea to me. I might like it if directory names always had to have a trailing /, but I am less motivated by "convenience of common cases" and much more by "absolute precision/specificity/unambiguity" belt and suspenders. (kind of unrelated but along the same lines, I toy with the idea of getting rid of . and .. visible in the filesystem, and make them only part of the syntax of paths. then you could have unambiguous multiple links to a directory: ".. is where you came from" and .. in the root is still the root, so chroot works too)
- m463 4mo agoI think . and .. are useful. there's also perforce's ... which I find interesting (for example foo/... means everything below directory "foo")
- JdeBP 4mo agoIndeed. This is one of the differences between the Unix and the MS/PC/DR-DOS command-line world. In the latter, recognizing empty final pathname components actually did become a way of differentiating such situations. I wrote a set of DOS and OS/2 tools in the 1990s, including COPY and MOVE commands, that had this very behaviour. I wasn't alone.