Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 May 1995 17:46:27 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        ache@freefall.cdrom.com, rgrimes@gndrsh.aac.dev.com
Cc:        CVS-commiters@freefall.cdrom.com, cvs-etc@freefall.cdrom.com
Subject:   Re: cvs commit: src/etc Makefile
Message-ID:  <199505140746.RAA19196@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>>   Modified:    etc       Makefile
>>   Log:
>>   Change ln -sf to rm -f and ln -s, first one work incorrectly
>>   for directories when called second time

>Thank you for fixing this for me, now the real questions is what is
>broken with ln -sf that makes it necessary to do this?

>Please open a pr about the fact that ln -sf does not quite do the right
>things for symbolic links to directories when called a second time.

It's working as intended (brokenly).  ln without -f follows symlinks to
determine if the target is a directory, so

	ln -s any existing-symlink-to-existing-dir

creates a symlink in the existing-dir.  The -f flag shouldn't change
this behaviour.  It doesn't change it in either FreeBSD ln or gnu ln.

The right way to handle this was for ln to default to not operating on
directories.  You would have had use a trailing slash in the file name
if you really wanted a directory.  ln wouldn't parse the slash but it
would use lstat() instead of stat() to determine if the target is a
directory.  The trailing slash (or its absence) makes lstat() DTRT
for symlinks to directories.

As it is, the bug is in the documentation.  ln.4 doesn't completely
document the behaviour for symlinks to directories.

ln.c names the target and source back to front.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199505140746.RAA19196>