Re: Buggy mv --interactive --reply=no, hopefully solved here

2005-05-10 Thread Jim Meyering
Vlada Macek [EMAIL PROTECTED] wrote:
 I still believe there is a bug in `mv'. Try to run

 mv --interactive --reply=no plain1 plain2

 and given both plains exist, plain2 gets overwritten. This is not
 expected behavior, not just by me (there is a Debian bug filled in).
 Command `cp' is not affected.

 The problem seems to be fixed by this:

 --- coreutils-cvs/src/copy.c2005-04-11 22:06:34.0 +0200
 +++ coreutils/src/copy.c2005-05-09 21:43:40.539405480 +0200

Thank you for the report and patch.
I've applied it, adjusted some comments, and added a test case.
The change is committed, but there will be some delay before
it reaches savannah.

2005-05-10  Jim Meyering  [EMAIL PROTECTED]

* src/copy.c (abandon_move): Remove erroneous UNWRITABLE check.
This makes `mv -i --reply=no f1 f2' work as expected (in not
performing the move operation).  But note that specifying `-i'
after `--reply=no' does *not* work.
Tiny patch from Vlada Macek.
Correct a comment.
* tests/mv/reply-no: New file.  Test for the above fix.
* tests/mv/Makefile.am (TESTS): Add reply-no.

Index: src/copy.c
===
RCS file: /fetish/cu/src/copy.c,v
retrieving revision 1.179
retrieving revision 1.180
diff -u -p -u -r1.179 -r1.180
--- src/copy.c  11 Apr 2005 20:06:34 -  1.179
+++ src/copy.c  10 May 2005 07:35:43 -  1.180
@@ -798,8 +798,8 @@ record_file (Hash_table *ht, char const
 
 /* When effecting a move (e.g., for mv(1)), and given the name DST_PATH
of the destination and a corresponding stat buffer, DST_SB, return
-   true if the logical `move' operation should not proceed.
-   Return true if it may proceed.
+   true if the logical `move' operation should _not_ proceed.
+   Otherwise, return false.
Depending on options specified in X, this code may issue an
interactive prompt asking whether it's ok to overwrite DST_PATH.  */
 static bool
@@ -808,8 +808,7 @@ abandon_move (const struct cp_options *x
   struct stat const *dst_sb)
 {
   assert (x-move_mode);
-  return ((x-interactive == I_ALWAYS_NO
-UNWRITABLE (dst_path, dst_sb-st_mode))
+  return (x-interactive == I_ALWAYS_NO
   || ((x-interactive == I_ASK_USER
|| (x-interactive == I_UNSPECIFIED
 x-stdin_tty


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Buggy mv --interactive --reply=no, hopefully solved here

2005-05-09 Thread Vlada Macek
Hi,

even after testing the recent anonymous checkout of

cvs -z3 -d:ext:[EMAIL PROTECTED]:/cvsroot/coreutils co coreutils

I still believe there is a bug in `mv'. Try to run

mv --interactive --reply=no plain1 plain2

and given both plains exist, plain2 gets overwritten. This is not
expected behavior, not just by me (there is a Debian bug filled in).
Command `cp' is not affected.

The problem seems to be fixed by this:

--- coreutils-cvs/src/copy.c2005-04-11 22:06:34.0 +0200
+++ coreutils/src/copy.c2005-05-09 21:43:40.539405480 +0200
@@ -805,14 +805,13 @@
 static bool
 abandon_move (const struct cp_options *x,
   char const *dst_path,
   struct stat const *dst_sb)
 {
   assert (x-move_mode);
-  return ((x-interactive == I_ALWAYS_NO
-UNWRITABLE (dst_path, dst_sb-st_mode))
+  return ((x-interactive == I_ALWAYS_NO)
   || ((x-interactive == I_ASK_USER
|| (x-interactive == I_UNSPECIFIED
 x-stdin_tty
 UNWRITABLE (dst_path, dst_sb-st_mode)))
(overwrite_prompt (dst_path, dst_sb), 1)
! yesno ()));


Please carbon me with replies, since I'm not on this list. Thanks.

-- 

\//\/\
(Sometimes credited as 1494 F8DD 6379 4CD7 E7E3 1FC9 D750 4243 1F05 9424.)



signature.asc
Description: OpenPGP digital signature
___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils