lobsters score: 2 · tags: linux, python
You must log in or register to comment.
I believe cp on Linux uses copy_file_range, not read and write. In addition to bypassing copies to and from userspace, this means that copy-on-write filesystems can avoid copying the data and can instead just add a new reference.
score 3 · canonical
In good tradition,
cpis also an example of a command with a surprising arsenal of footguns. Idempotency was apparently not its design goal.If it wasn’t for the goal of compatibility, I would be tempted to make some adjustments (I think someone needs to do this):
--no-clobbershould probably have been the default. Or succeed if they are already duplicates.- … also when the destination argument happens to exist as a directory
- … unless intended to be a directory – ends on
/: Rsync behaves consistently in this case:cp/rsync --recursive ~/Documents/ /mnt/backup/Documents/: Only Rsync does the same the first and the second time.
- Add something like an
--mkdiroption, so you don’t need to repeat yourself if the destination is in a directory.
score 3 · canonical

