]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(copy): Comment change to avoid overwriting source with backup.
authorJim Meyering <jim@meyering.net>
Sat, 9 Mar 1996 04:59:22 +0000 (04:59 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 9 Mar 1996 04:59:22 +0000 (04:59 +0000)
src/cp.c

index af322438d25774b45aa7972a3c7138a6260c096b..3b0886e766226a6fb1773c0c2a7a1f2c72e3b4fa 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -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,