GNU bug report logs - #36901
mv: merge directories where target already exists

Previous Next

Package: coreutils;

Reported by: L A Walsh <coreutils <at> tlinx.org>

Date: Sat, 3 Aug 2019 03:35:02 UTC

Severity: wishlist

Full log


Message #21 received at 36901 <at> debbugs.gnu.org (full text, mbox):

From: L A Walsh <coreutils <at> tlinx.org>
To: Assaf Gordon <assafgordon <at> gmail.com>
Cc: 36901 <at> debbugs.gnu.org
Subject: Re: bug#36901: Enhance directory and file moves where target already
 exists
Date: Fri, 02 Aug 2019 23:21:43 -0700

On 2019/08/02 23:10, Assaf Gordon wrote:

>>>> So when I look at the system call on linux for rename:
>>>>         oldpath can specify a directory.  In this case, newpath must
>>>>         either not
>>>>         exist, or it must specify an empty directory.
>>>>          (complying with POSIX_C_SOURCE >= 200809L)


>>>> So mv is violating POSIX - it didn't do the rename, but moved
>>>> A under B and neither dir had to be empty.
>>>>
>>>> Saying it has to follow POSIX when it doesn't appear to, seems
>>>> a bit contradictory?
> 
> I previously quoted one small part of the entire "mv" POSIX specification
> (item #3, regarding using the 'rename(2)' function).
> 
> It would be wise to read the entire specification before making claims
> about violating POSIX.
----
	One doesn't need to read all federal and state laws before 
making claims of law violation.


> 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.

But it isn't.  Note to mention -- which posix?  Different posix versions
are not the same.

It isn't 1 spec consistent spec, but changes overtime.  You quoted
a section saying it had to follow the behavior of rename, but it doesn't
do that:


And it doesn't follow the POSIX section quoted on the manpage.

>>>>         oldpath can specify a directory.  In this case, newpath must
>>>>         either not
>>>>         exist, or it must specify an empty directory.
>>>>          (complying with POSIX_C_SOURCE >= 200809L)

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.





This bug report was last modified 5 years and 313 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.