bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug#389170: coreutils: mv -v fails on hardlinked files


From: Jim Meyering
Subject: Re: Bug#389170: coreutils: mv -v fails on hardlinked files
Date: Sun, 24 Sep 2006 21:33:27 +0200

Marc Lehmann <address@hidden> wrote:
> Version: 5.97-5
>
> "mv -v" does not output anything when it moves one hardlink of a file over 
> another:
>
>    cerebro /tmp/tst# touch a
>    cerebro /tmp/tst# touch b
>    cerebro /tmp/tst# mv -v a b
>    `a' -> `b'
>    cerebro /tmp/tst# touch x
>    cerebro /tmp/tst# ln x y
>    cerebro /tmp/tst# mv -v x y
>    cerebro /tmp/tst#
>
> The second mv should output `x' -> `y', but doesn't output anything (the
> operation is correctly executed, though).

Thanks for the report.
I've fixed that.  Though it doesn't print what you suggest.
Now it does this:

    $ touch x; ln x y; mv -v x y
    removed `x'

2006-09-24  Jim Meyering  <address@hidden>

        * NEWS: Mention these fixes.
        * src/copy.c (copy_reg): With --verbose (-v), print
        "removed `file_name'" just after unlinking a file.
        (copy_internal): Likewise, in three more places.
        Marc Lehman reported that "touch x; ln x y; mv -v x y" was silent.
        * tests/mv/hard-verbose: New file.  Test for the above fix.
        * tests/mv/Makefile.am (TESTS): Add hard-verbose.

Index: src/copy.c
===================================================================
RCS file: /fetish/cu/src/copy.c,v
retrieving revision 1.212
retrieving revision 1.213
diff -u -p -u -r1.212 -r1.213
--- src/copy.c  20 Sep 2006 17:32:14 -0000      1.212
+++ src/copy.c  24 Sep 2006 19:28:25 -0000      1.213
@@ -296,6 +296,8 @@ copy_reg (char const *src_name, char con
              return_val = false;
              goto close_src_desc;
            }
+         if (x->verbose)
+           printf (_("removed %s\n"), quote (dst_name));

          /* Tell caller that the destination file was unlinked.  */
          *new_dst = true;
@@ -1061,6 +1063,8 @@ copy_internal (char const *src_name, cha
                     doesn't end up removing the source file.  */
                  if (rename_succeeded)
                    *rename_succeeded = true;
+                 if (unlink_src && x->verbose)
+                   printf (_("removed %s\n"), quote (src_name));
                  return true;
                }
              if (unlink_src)
@@ -1240,6 +1244,8 @@ copy_internal (char const *src_name, cha
                  return false;
                }
              new_dst = true;
+             if (x->verbose)
+               printf (_("removed %s\n"), quote (dst_name));
            }
        }
     }
@@ -1344,6 +1350,8 @@ copy_internal (char const *src_name, cha
                  error (0, errno, _("cannot remove %s"), quote (dst_name));
                  goto un_backup;
                }
+             if (x->verbose)
+               printf (_("removed %s\n"), quote (dst_name));
              link_failed = (link (earlier_file, dst_name) != 0);
            }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]