diff options
author | Jim Meyering <jim@meyering.net> | 1996-03-09 04:59:22 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1996-03-09 04:59:22 +0000 |
commit | 8ddd60a387c96da371f32c157974dd164e061a52 (patch) | |
tree | 9af2d2a9e467d0140eb2e7d17339ae9adc06a3b7 | |
parent | eaf359df0c2674158628fb0932560d2b10feb195 (diff) | |
download | coreutils-8ddd60a387c96da371f32c157974dd164e061a52.tar.xz |
(copy): Comment change to avoid overwriting source with backup.
-rw-r--r-- | src/cp.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -620,6 +620,11 @@ copy (char *src_path, char *dst_path, int new_dst, dev_t device, char *tmp_backup = find_backup_file_name (dst_path); if (tmp_backup == NULL) error (1, 0, _("virtual memory exhausted")); + + /* Detect (and fail) when creating the backup file would + destroy the source file. Before, running the commands + cd /tmp; rm -f a a~; : > a; echo A > a~; cp -b -V simple a~ a + would leave two zero-length files: a and a~. */ if (strcmp (tmp_backup, src_path) == 0) { error (0, 0, |