[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/4] copy: make backup files more reliably
From: |
Kamil Dudka |
Subject: |
Re: [PATCH 3/4] copy: make backup files more reliably |
Date: |
Thu, 03 Aug 2017 12:44:43 +0200 |
User-agent: |
KMail/4.14.10 (Linux/4.9.34-gentoo; KDE/4.14.32; x86_64; ; ) |
On Tuesday, August 01, 2017 13:19:33 Paul Eggert wrote:
> Kamil Dudka wrote:
> > If the user
> > explicitly asks for a simple backup, cp should either make a single
> > backup or fail honestly if the simple backup cannot be made.
>
> Fair enough. I installed the attached additional patch to do that. Although
> this reintroduces a race, I guess we've lived with the race for quite some
> time.
Still not perfect. Now it produces false positives with --backup=existing:
% cp --version | head -1
cp (GNU coreutils) 8.27.65-81a05
% touch a
% ln a a~
% cp -v --backup=numbered a~ a
'a~' -> 'a' (backup: 'a.~1~')
% cp -v --backup=existing a~ a
cp: backing up 'a' would destroy source; 'a~' not copied
As for the test, could it be simplified like this?
--- a/tests/cp/backup-is-src.sh
+++ b/tests/cp/backup-is-src.sh
@@ -25,12 +25,10 @@ echo a-tilde > a~ || framework_failure_
# This cp command should exit nonzero.
cp --b=simple a~ a > out 2>&1 && fail=1
-sed "s,cp:,XXX:," out > out2
-
cat > exp <<\EOF
-XXX: backing up 'a' would destroy source; 'a~' not copied
+cp: backing up 'a' would destroy source; 'a~' not copied
EOF
-compare exp out2 || fail=1
+compare exp out || fail=1
Exit $fail