On 17/12/10 16:11, Pádraig Brady wrote: > I also notice more warnings and a possible > uninitialized stat buf in cp.c. > I'll have a look at these later...
That was another buglet fixed with: commit b0cce8793c0b7a305f0f336e2f563ea941c44a92 Author: Pádraig Brady <[email protected]> Date: Sat Dec 18 02:50:33 2010 +0000 cp: ensure backups are created when -T specified * src/cp.c (do_copy): When -T is specified, initialise the NEW_DST and SB variables, which are checked when running: cp -T --force --backup file file diff --git a/src/cp.c b/src/cp.c index 5b14f3a..3d00b5f 100644 --- a/src/cp.c +++ b/src/cp.c @@ -604,6 +604,8 @@ do_copy (int n_files, char **file, const char *target_directory, error (0, 0, _("extra operand %s"), quote (file[2])); usage (EXIT_FAILURE); } + /* Update NEW_DST and SB, which may be checked below. */ + ignore_value (target_directory_operand (file[n_files -1], &sb, &new_dst)); } else if (!target_directory) { diff --git a/tests/cp/backup-1 b/tests/cp/backup-1 index 94c1f2a..fb1c00b 100755 --- a/tests/cp/backup-1 +++ b/tests/cp/backup-1 @@ -30,8 +30,8 @@ echo test > $file || fail=1 # Specify both version control and suffix so the environment variables # (possibly set by the user running these tests) aren't used. -cp --force --backup=simple --suffix=$suffix $file $file \ - || fail=1 +cp --force --backup=simple --suffix=$suffix $file $file || fail=1 +cp -T --force --backup=simple --suffix=$suffix $file $file || fail=1 test -f $file || fail=1 test -f $file_backup || fail=1
