Subject: Re: bug#15232: cp -i a/s b/s c

From: Pádraig Brady <[email-masked]>
Date: Sun, 01 Sep 2013 18:34:01 +0100

On 09/01/2013 08:37 AM, [email-masked] 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.