Subject: bug#17087: cp -i/yes gets ignored

From: Pádraig Brady <[email-masked]>
Date: Wed, 26 Mar 2014 14:20:13 +0000

On 03/26/2014 01:26 PM, Bernhard Voelker wrote:
> On 03/25/2014 07:25 AM, Paul Eggert wrote:
>> (the second is just a code cleanup).
> 
> Oops, that 2nd patch
>   http://git.sv.gnu.org/cgit/coreutils.git/commit/?id=7f669b40
> now produces the following check failure:
> 
> FAIL: tests/mv/i-3
> ==================

That's an interesting one. I guess our CI didn't flag this
as the test is skipped without a controlling tty:
http://hydra.nixos.org/jobset/gnu/coreutils-master

Also the test is skipped with a parallel make check!
I.E. this first command detects the fail, while the second skips the test:
  $ make -j2 check TESTS="tests/mv/i-3.sh"
  $ make -j2 check TESTS="tests/mv/i-2.sh tests/mv/i-3.sh"

So to handle both cases I'm updating the "release tasks" list to:
  setsid make check $(($(nproc) * 2)) # tests without controlling tty
  make check -j1 # tests with controlling tty

> BTW: in check_overwrite_prompt, the file 'out' contains
>   "mv: unwritable 'g' (mode 0000, ---------); try anyway?"

That should have been apparent in the test log immediately,
without you having to add debug.

In general we should allow these patches a little
while for review before pushing.

Hopefully the attached fixes up these issues.

thanks,
Pádraig.
>From 8d7e4222e14f3d967c5b0efc10e34a97f32ae320 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email-masked]>
Date: Wed, 26 Mar 2014 13:36:16 +0000
Subject: [PATCH] mv: fix issues with previous prompt adjustments

* src/copy.c (overwrite_ok): Fix the gettext calls so
that the second string is tagged for translation.
Display the correct "replace ..." prompt when in move_mode.
* tests/mv/i-3.sh: Display the output on failure to ease debugging.
---
 src/copy.c      |    8 ++++----
 tests/mv/i-3.sh |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/copy.c b/src/copy.c
index 71813dc..781cc1e 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->move_mode || 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]);
diff --git a/tests/mv/i-3.sh b/tests/mv/i-3.sh
index 690af73..8c58d5d 100755
--- a/tests/mv/i-3.sh
+++ b/tests/mv/i-3.sh
@@ -52,7 +52,7 @@ check_overwrite_prompt()
 }
 
 # Wait for up to 12.7 seconds for the expected prompt.
-retry_delay_ check_overwrite_prompt .1 7 || fail=1
+retry_delay_ check_overwrite_prompt .1 7 || { fail=1; cat out; }
 
 kill $pid
 
-- 
1.7.7.6