[Top][All Lists]

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

mv does not overwrite directories: document, please

From: Bernhard Voelker
Subject: mv does not overwrite directories: document, please
Date: Tue, 1 Dec 2015 10:10:18 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

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:

[1] POSIX:

Have a nice day,

reply via email to

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