[Top][All Lists]

[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 16:55:31 +0000

> Note that the underlying rename would fail on Linux 2.6.x and *BSD
> (but it'd succeed on Solaris 9 and 10):
>   $ touch a; rm -rf b; perl -e 'rename "a", "b/" or die "$!"'

The difference is whether a is a directory or a regular file.
When a is not a directory, I would expect rename("a", "b/")
to fail because it would attempt to create a directory (although
that may be a defect in POSIX for not explicitly mentioning this
case).  But when a is a directory, I see no reason why rename
cannot succeed.

>   Not a directory at -e line 1.
>   [Exit 20]
> Currently, mv detects this particular `problem' without performing
> an actual rename, so it's more consistent than it would be if it
> were relying on the actual system call.

Which problem, the issue of moving a non-directory into
something that looks like a directory because of the
trailing slash, or the issue of moving a directory to another

Eric Blake

reply via email to

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