https://unix.stackexchange.com/questions/82485/when-wouldnt-...
It seems that recursive by default would have been much more intuitive.
https://unix.stackexchange.com/questions/82485/when-wouldnt-...
It seems that recursive by default would have been much more intuitive.
Yes, seriously. When you read about the supposed evils of cat -v from the Unix nostalgia people, remember that it was the same people who gave cat its -v option who also gave cp its -r option, in 4.2BSD.
It took over half a decade to percolate out of the BSD world, too. AT&T Unix System 5 did not have an -r option to cp. Here's Brandon S. Allbery explaining in 1987 how one copies directories on AT&T Unix System 5 Releases 2/3 by combining find and cpio -p:
* https://groups.google.com/g/comp.unix.questions/c/XiumTgkcYR...
Originally we read directories as raw byte streams and liked it, you know. (-:
Then the people who complained about cat -v went ahead and made better Unix, called Plan 9, in which moving (as opposed to merely renaming) a directory is impossible: instead, you're supposed to do mkdir && dircp && rm -r. Which is quite a choice, if I say so myself: there is simply no low-level primitive (syscall or 9p message) for moving files across directories, even on the same file server. Their version of mv can move files across the directories, but it's still done with internal equivalent of cp+rm.
Afterwards they made a better Plan 9, called Inferno, with a safer userspace programming language, leaving their C creation only for kernel code, and DisVM implementation.
tar cf - . | ( cd /new/path; tar xpf - )
or thereabouts, because at the time, `tar` was more than capable of doing all the filesystem tricks that `cp` was clumsy with, and we understood this idiom well. You could also `dump` an entire block device.I believe that my motivation was that the Unix wars were still raging hotly; as a sysadmin I needed portable skills and I wasn't tied or certified to one vendor's Unix, and therefore I sought out idioms that worked on SunOS, HP/UX, AIX, BSD, you name it. "cp -r" didn't enjoy that stable support at the time.
I use pax -r -w most of the time.
And... the worst thing is I don't really remember why(shakes fist at past me "write better comments"). Probably to do with how cpio's weird file selection actually worked well with it's use case. It reads a filtered list of files from one directory then uses that to copy only those filenames from another directory back into it.