bug-coreutils
[Top][All Lists]
Advanced

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

Re: "mv a b/" when b does not exist


From: Eric Blake
Subject: Re: "mv a b/" when b does not exist
Date: Tue, 29 Nov 2005 06:44:00 -0700
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Paul Eggert on 11/28/2005 10:57 AM:
>>mv a b/
>>
>>mv: target `b/' is not a directory: No such file or directory
>>
> 
> As I understand it, POSIX says that "mv a b/" is equivalent to
> rename("a", "b/"),

Correct.

> and that the latter should fail when the directory
> "b" does not exist.

That, I'm not sure about.  I reread
http://www.opengroup.org/onlinepubs/009695399/functions/rename.html, and
all I can see is "If the old argument points to the pathname of a
directory, the new argument shall not point to the pathname of a file that
is not a directory."  Then there is the overriding rule in XBD 4.11 that
"A pathname that contains at least one non-slash character and that ends
with one or more trailing slashes shall be resolved as if a single dot
character ( '.' ) were appended to the pathname," but I read that as
rename() sees that "a" is a directory, so it resolves "b/" as "b/." to
ensure that b/ is not the pathname of a non-directory (it isn't, since
"b/." does not exist), then can go ahead and do the rename to the original
"b/".  I don't see anything in POSIX that forbids Linux's behavior of
being successful on the rename.

>  So the old mv behavior did not conform to POSIX,
> and the new mv behavior does.
> 
> Admittedly it is a murky area.  One could argue that if Linux
> rename("a", "b/") works (contrary to POSIX), then mv should defer to
> rename and contradict POSIX as well.  For what it's worth, Solaris 10
> mv and OpenBSD 3.4 mv behave the old way, so there is a
> sideways-compatibility argument here as well.

I would agree with Tim in arguing that mv(1) should succeed in the
mentioned case, and that the new behavior of failing is indeed a regression.

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDjFsg84KuGfSFAYARAk+yAKDOkZEwnUMCTgdz+jSUKuUrhU5sdgCfaP05
+dgWomx8o98j+RFTjrQPGx4=
=Pn8M
-----END PGP SIGNATURE-----




reply via email to

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