Subject: bug#36901: Enhance directory and file moves where target already exists

From: Bernhard Voelker <[email-masked]>
Date: Tue, 6 Aug 2019 21:14:24 +0200

On 8/3/19 8:21 AM, L A Walsh wrote:
> On 2019/08/02 23:10, Assaf Gordon wrote:
>> Specifically, at the top of the page:
>> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/mv.html
>>    SYNOPSIS
>>       mv [-if] source_file target_file
>>       mv [-if] source_file... target_dir
>>    DESCRIPTION
>>       [...]
>>       In the second synopsis form, mv shall move each file named by a
>>       source_file operand to a destination file in the existing directory
>>       named by the target_dir operand [...] This second form is assumed
>>       when the final operand names an existing directory
>>
>> In this regard GNU 'mv' is compliant with POSIX.

[...]

> mkdir A B
> touch A/foo B/fee
> mv A B
> 
> It B exists and is not empty.  Ergo, it is not following the 
> requirement that the directory must be empty or not exist.

There no such condition in the POSIX citation (nor in the whole mv(1) spec)
about whether 'B' is empty or not.  The question is whether the target operant
is an existing directory (or a symlink which resolves to one).

Regards,
Berny