Subject: Re: Linux emulation and mkdir with trailing /
To: Andrew Brown <atatat@atatdot.net>
From: Greywolf <greywolf@starwolf.com>
List: tech-kern
Date: 09/28/2000 23:37:07
On Fri, 29 Sep 2000, Andrew Brown wrote:

# it seems that a file can replace a file by the same name and a
# directory can replace an *empty* directory by the same name.  this
# means that the following command will work twice, but not three times.
# 
#    % cd /tmp ; mkdir -p foo/bar ; mv foo frotz
# 
# i was surprised when i saw that it worked twice.

...why?

1.	rename foo to frotz.  Straight up, since frotz didn't exist.

2.	rename foo to frotz/foo, since frotz/foo didn't exist before.

3.	Fails because frotz/foo exists and is not empty.  It's not trying
	to clobber frotz directly.

Seems very UNIX-like to me :-)

				--*greywolf;
--
BSD: the devil made me do it.