From owner-freebsd-commit Sun May 14 00:47:19 1995 Return-Path: commit-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id AAA28788 for commit-outgoing; Sun, 14 May 1995 00:47:19 -0700 Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id AAA28769 for cvs-etc-outgoing; Sun, 14 May 1995 00:47:12 -0700 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.34]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id AAA28732 ; Sun, 14 May 1995 00:46:40 -0700 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id RAA19196; Sun, 14 May 1995 17:46:27 +1000 Date: Sun, 14 May 1995 17:46:27 +1000 From: Bruce Evans Message-Id: <199505140746.RAA19196@godzilla.zeta.org.au> To: ache@freefall.cdrom.com, rgrimes@gndrsh.aac.dev.com Subject: Re: cvs commit: src/etc Makefile Cc: CVS-commiters@freefall.cdrom.com, cvs-etc@freefall.cdrom.com Sender: commit-owner@FreeBSD.org Precedence: bulk >> 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