Subject: bug#17087: closed (Re: bug#17087: cp -i/yes gets ignored)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 25 Mar 2014 11:12:03 +0000

Your bug report

#17087: cp -i/yes gets ignored

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
17087: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17087
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#17087: cp -i/yes gets ignored
From: Pádraig Brady <[email-masked]>
To: Paul Eggert <[email-masked]>
Cc: [email-masked], Karl Berry <[email-masked]>
Date: Tue, 25 Mar 2014 11:10:19 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

On 03/25/2014 06:25 AM, Paul Eggert wrote:
> Pádraig Brady wrote:
>> That code has been there "from the beginning" and I'm guessing it's
>> to prompt users to allow them to chmod the file in a separate terminal?
> 
> If we go back far enough (i.e., before commit 6bf3479 dated 2000-08-27), this message was output only if -f was also given.

Things have flipped around a bit. Originally no prompts were output at all with --force (which was incorrect).

> More recently we've seen similar complaints, e.g.: http://lists.gnu.org/archive/html/bug-coreutils/2007-03/msg00130.html

Ah thanks for linking that.

> At least the diagnostic wording could be improved so that users who are prompted don't get the false impression that the copy will succeed; POSIX clearly allows this.  I installed the attached patches (the second is just a code cleanup).  Perhaps that's enough.

Looks good.

It will need adjustment so that the second string is tagged for translation.
I'll apply the following:

diff --git a/src/copy.c b/src/copy.c
index 71813dc..68b4c5e 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -1575,10 +1575,10 @@ overwrite_ok (struct cp_options const *x, char const *dst_name,
       strmode (dst_sb->st_mode, perms);
       perms[10] = '\0';
       fprintf (stderr,
-               _((x->unlink_dest_before_opening
-                  || x->unlink_dest_after_failed_open)
-                 ? "%s: replace %s, overriding mode %04lo (%s)? "
-                 : "%s: unwritable %s (mode %04lo, %s); try anyway? "),
+               (x->unlink_dest_before_opening
+                || x->unlink_dest_after_failed_open)
+               ? _("%s: replace %s, overriding mode %04lo (%s)? ")
+               : _("%s: unwritable %s (mode %04lo, %s); try anyway? "),
                program_name, quote (dst_name),
                (unsigned long int) (dst_sb->st_mode & CHMOD_MODE_BITS),
                &perms[1]);

Marking this bug as done.

thanks,
Pádraig.

Subject: cp -i/yes gets ignored
From: [email-masked] (Karl Berry)
To: [email-masked]
Date: Mon, 24 Mar 2014 16:17:33 GMT
List-Id: <debbugs-submit.debbugs.gnu.org>

I find it annoying that explicitly answering "y" to an interactive
prompt in cp can get ignored:

$ touch foo
$ chmod 444 foo
$ cp -i /etc/issue foo
cp: try to overwrite 'foo', overriding mode 0444 (r--r--r--)? y
cp: cannot create regular file 'foo': Permission denied

It seems to me, in terms of UI, that this is clearly at least as
"forceful" (I would say more so) than -f, which does do the overwrite.

Also, both mv -i and rm -i already perform their action on a readonly
file when told "y"es.  So simple consistency is another argument that cp
should do the same.

Jim told me once that this behavior is specified by POSIX.  Hardly
surprising.  Can we DTRT here by default and reserve the stupid behavior
for POSIXLY_CORRECT?

Curmudgeonly,
Karl