GNU bug report logs - #15232
cp: "-i a/s b/s c" ask for confirmation then still fails

Previous Next

Package: coreutils;

Reported by: jidanni <at> jidanni.org

Date: Sun, 1 Sep 2013 07:40:01 UTC

Severity: wishlist

Tags: confirmed

Full log


View this message in rfc822 format

From: Pádraig Brady <P <at> draigBrady.com>
To: jidanni <at> jidanni.org
Cc: 15232 <at> debbugs.gnu.org
Subject: bug#15232: cp -i a/s b/s c
Date: Sun, 01 Sep 2013 18:34:01 +0100
On 09/01/2013 08:37 AM, jidanni <at> jidanni.org wrote:
> $ cp -i a/s b/s c
> cp: overwrite ‘c/s’? y
> cp: will not overwrite just-created ‘c/s’ with ‘b/s’
> Mmmm OK, but maybe don't ask then.

This is a fair point.
There are two ways to handle this.
1. Do allow the overwrite if 'y' answered.
2. Don't prompt and just display the error.

Case 1 could be useful if you wanted to give
priority to the last item copied in.
However there would be an ambiguity in that case,
as you wouldn't know if the prompt was for an
existing file or a newly copied file.
Also that use case is handled with -n anyway,
by just ordering the parameters according to priority.
So option 2 as you suggest seems like the right thing to do.

So this is a generally means we might only prompt
_after_ we discount all cases that aren't allowed.
Another for example is:

$ rm -f c/s && mkdir c/s && cp -i a/s b/s c
cp: overwrite `c/s'? y
cp: cannot overwrite directory `c/s' with non-directory
cp: overwrite `c/s'? y
cp: cannot overwrite directory `c/s' with non-directory

But then on the other hand, if you did answer 'n' above,
the exit code from cp would be 'success' rather than 'failure'.
I.E. it would be a change in behavior to adjust this,
rather than just a prompt avoidance.
I.E. it's only a redundant prompt when you answer 'y'.

So I'm inclined to leave this as is?

thanks,
Pádraig.




This bug report was last modified 6 years and 299 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.