--- Begin Message ---
Subject: |
Simple backup swaps source and destination files |
Date: |
Tue, 19 Apr 2022 19:05:09 -0400 |
When doing mv or cp with --backup=simple, if an existing file in
DIRECTORY has the same name as SOURCE, the files appear to be swapped
instead of an in-place backup of the original file in DIRECTORY being
made.
It doesn't happen with --backup=numbered. SIMPLE_BACKUP_SUFFIX is not set.
Steps to reproduce:
$ mkdir tmp
$ echo "first file" > tmp/a
$ echo "second file" > a
$ command mv -v --backup=simple a tmp/
renamed 'a' -> 'tmp/a' (backup: 'tmp/a~')
$ cat tmp/a~
cat: tmp/a~: No such file or directory
$ cat a~
first file
Version info:
$ mv --version | head -n 1
mv (GNU coreutils) 9.1
$ uname -srm
Linux 5.17.3-arch1-1 x86_64
$ ldd --version | head -n 1
ldd (GNU libc) 2.35
The filesystem type is ext4.
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#55029: Simple backup swaps source and destination files |
Date: |
Wed, 20 Apr 2022 19:53:06 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 |
On 4/19/22 16:05, Steve Ward wrote:
When doing mv or cp with --backup=simple, if an existing file in
DIRECTORY has the same name as SOURCE, the files appear to be swapped
instead of an in-place backup of the original file in DIRECTORY being
made.
Thanks for the bug report. That's new to coreutils 9.1, and is a big
enough fail that it suggests we'll need a 9.2 sooner rather than later.
I introduced the bug when fixing an earlier bug (sorry).
I installed the attached Gnulib patch, which should fix the bug in
Coreutils, with the attached two Coreutils patches to update to the
latest Gnulib, and to add a test case for the bug.
0001-backupfile-fix-bug-when-renaming-simple-backups.patch
Description: Text Data
0001-build-update-gnulib-submodule-to-latest.patch
Description: Text Data
0002-mv-test-Bug-55029.patch
Description: Text Data
--- End Message ---