Wyatt (🏳️⚧️♀?) on Nostr: TL;DR just do rm -rf thing-to-replace; cp -R source dest. -r is a newish thing ...
TL;DR just do rm -rf thing-to-replace; cp -R source dest.
-r is a newish thing (introduced to POSIX in 2017 as -R (uppercase), though GNU cp did it a long time before then) that in my opinion should never have been added, just so you know. DOS didn't even easily let you delete dirs and everything in them recursively before version 6 (DELTREE). The old unix way to copy directories was something like tar cf - sourcedir | (cd /destination-parent; tar xf -) if you wanted to make a dir called 'sourcedir' in the destination, or else cd sourcedir; tar cf - . | (cd /path/to/destdir; tar xf -) to copy the files inside the dir instead of the dir itself.
in DOS, you'd use xcopy to work on directories, not the normal "copy" command. Because "copy" was rigidly defined as being for files, much like unix cp originally was.
cp -r is a nice shorthand but it also introduces the inconsistency that you speak of. Because cp was originally not intended to work on directories at all.
-r is a newish thing (introduced to POSIX in 2017 as -R (uppercase), though GNU cp did it a long time before then) that in my opinion should never have been added, just so you know. DOS didn't even easily let you delete dirs and everything in them recursively before version 6 (DELTREE). The old unix way to copy directories was something like tar cf - sourcedir | (cd /destination-parent; tar xf -) if you wanted to make a dir called 'sourcedir' in the destination, or else cd sourcedir; tar cf - . | (cd /path/to/destdir; tar xf -) to copy the files inside the dir instead of the dir itself.
in DOS, you'd use xcopy to work on directories, not the normal "copy" command. Because "copy" was rigidly defined as being for files, much like unix cp originally was.
cp -r is a nice shorthand but it also introduces the inconsistency that you speak of. Because cp was originally not intended to work on directories at all.