From: Jim Meyering Date: Sat, 9 Mar 1996 04:59:22 +0000 (+0000) Subject: (copy): Comment change to avoid overwriting source with backup. X-Git-Tag: FILEUTILS-3_12j~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ddd60a387c96da371f32c157974dd164e061a52;p=thirdparty%2Fcoreutils.git (copy): Comment change to avoid overwriting source with backup. --- diff --git a/src/cp.c b/src/cp.c index af322438d2..3b0886e766 100644 --- 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,