bug-coreutils
[Top][All Lists]
Advanced

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

Re: Bug#389432: mv: cannot move directory into an already populated dire


From: Jim Meyering
Subject: Re: Bug#389432: mv: cannot move directory into an already populated directory
Date: Mon, 25 Sep 2006 23:51:38 +0200

Martin Waitz <address@hidden> wrote:
> Package: coreutils
> Version: 5.97-5
> Severity: normal
>
> hoi :)
>
> I tried to move all files from one directory tree into another tree with
> a similiar directory structure.  But "mv" gave up, complaining about
> "cannot move into own subdirectory", which confused me.
>
> Here a simple sequence for reproduction:
>
>       $ mkdir -p 1/a/b 2/a/c
>       $ mv 1/a 2/
>       mv: cannot move `1/a' to a subdirectory of itself, `2/a'
>       $ rmdir 2/a/c
>       $ mv 1/a 2/
>       $
>
> I expected mv to move 1/a/b to 2/a/b and then remove 1/a
> (no need to move 1/a, as 2/a already existed)

Thanks for the report, but mv can't do that -- at least not by default.
mv works mainly by making the "rename" syscall.  In some unusual cases
(like when src and dest are hard links), it can get away with just
unlinking the source file.  However, rename fails when the destination
is a nonempty directory, as in your example above.

True, that diagnostic is misleading, and the newer coreutils-6.2
gives a more useful message:

    $ mkdir -p 1/a/b 2/a/c
    $ mv 1/a 2/
    mv: cannot move `1/a' to `2/a': Directory not empty
    [Exit 1]

A stable coreutils-6.3 should be available soon.

It might make sense to add an option to make mv work this way,
if you can make a good enough case for it.




reply via email to

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