diff options
-rw-r--r-- | src/cp.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -25,7 +25,9 @@ #include <stdio.h> #include <sys/types.h> +/* FIXME: uncomment for release #define NDEBUG +*/ #include <assert.h> #include <getopt.h> @@ -521,17 +523,22 @@ do_copy (int argc, char **argv, const struct cp_options *x) where SUFFIX is determined by any version control options used. */ if (x->force - && backup_type != none + && x->backup_type != none && STREQ (source, dest) && !new_dst && S_ISREG (sb.st_mode)) { - new_dest = find_backup_file_name (dest); - /* Set backup_type to `none' so that the normal backup + static struct cp_options x_tmp; + + new_dest = find_backup_file_name (dest, x->backup_type); + /* Set x->backup_type to `none' so that the normal backup mechanism is not used when performing the actual copy. backup_type must be set to `none' only *after* the above call to find_backup_file_name -- that function uses backup_type to determine the suffix it applies. */ - backup_type = none; + x_tmp = *x; + x_tmp.backup_type = none; + x = &x_tmp; + if (new_dest == NULL) error (1, 0, _("virtual memory exhausted")); } @@ -743,8 +750,7 @@ main (int argc, char **argv) usage (1); } - if (make_backups) - backup_type = get_version (version); + x.backup_type = (make_backups ? get_version (version) : none); if (x.preserve == 1) x.umask_kill = 0777777; |