coreutils
[Top][All Lists]
Advanced

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

Re: mv does not overwrite directories: document, please


From: Pádraig Brady
Subject: Re: mv does not overwrite directories: document, please
Date: Tue, 1 Dec 2015 11:14:42 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 01/12/15 09:10, Bernhard Voelker wrote:
> Test case from a downstream bug report [0]:
> 
>    $ mkdir -p dir1 dir2/dir1 && touch dir2/dir1/file
> 
>    $ src/mv dir1 dir2
>    src/mv: cannot move 'dir1' to 'dir2/dir1': Directory not empty
> 
> FWIW the same applies to the case where SOURCE and TARGET are on
> different file systems:
> 
>    $ mv -v dir1 /tmp/dir2
>    mv: inter-device move failed: ‘dir1’ to ‘/tmp/dir2/dir1’; \
>      unable to remove target: Directory not empty
> 
> mv(1) calls rename(2) and the kernel returns ENOTEMPTY, so according
> to POSIX [1], mv(1) should write an error diagnostic and continue
> with other arguments.
> 
> So far, mv(1) works as designed ... but the OP of the original bug
> is right when he says that this behaviour is not documented.
> The Texinfo manual does not mention what happens when the target
> exists and is a directory.  The user may expect mv(1) to overwrite
> the existing 'dir2', especially as the docs claim:
> 
>    'mv' can move any type of file [...]
> 
> Can anyone think of a nice sentence (without being as complicated
> as in my German-tainted English ;-)?
> 
> [0] Dowstream bug:
> https://bugzilla.suse.com/show_bug.cgi?id=954549
> 
> [1] POSIX:
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/mv.html

A related recent commit with all test cases is:
http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=v8.21-98-g2bdb74e

I suppose the text would be summarized like:

Note, mv will only replace empty directories in the destination,
with existing populated directories skipped with a diagnostic.

thanks,
Pádraig.



reply via email to

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