From owner-freebsd-questions Sun Jul 9 16:35:24 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mail.rz.uni-ulm.de (sirius-ether.rz.uni-ulm.de [134.60.1.36]) by hub.freebsd.org (Postfix) with ESMTP id E738437B90E for ; Sun, 9 Jul 2000 16:35:19 -0700 (PDT) (envelope-from siegbert.baude@gmx.de) Received: from gmx.de (lilith.wohnheim.uni-ulm.de [134.60.106.64]) by mail.rz.uni-ulm.de (8.9.3/8.9.3) with ESMTP id BAA00125; Mon, 10 Jul 2000 01:35:11 +0200 (MEST) Message-ID: <39690C27.C180DC02@gmx.de> Date: Mon, 10 Jul 2000 01:35:03 +0200 From: Siegbert Baude X-Mailer: Mozilla 4.73 [en] (X11; I; FreeBSD 4.0-STABLE i386) X-Accept-Language: de, en MIME-Version: 1.0 To: Mike Meyer , "freebsd-questions@freebsd.org" Subject: Re: Replacing symbolic link to directory References: <14695.48116.939565.809592@guru.mired.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > That's the clue as to what's going on. It's telling you it created a > link called "d3/d2" to the directory d2. When the target of ln is a > directory - or a link to one - the target file is changed to be a file > with the basename of the original file. Is there a way to do what I wanted to achieve: Replace an already existing symbolic link to a directory with one command? For general discussion: The strength of UNIX is to consequently apply simple principles. So compared with the behaviour of rm and ls (see examples below), I would expect ln to make a difference between: ln -fs d1 d2 -> replacing the existing symbolic link d2 ln -fs d1 d2/ -> replacing the existing symbolic link d2/d1 This is maybe a question about UNIX philosophy or Stone Age design decisions (I just tried and the behaviour of ln is exactly the same with GNU ln on Solaris and Linux, and within BeOS), but there actually is a difference between a symbolic link to a directory and a directory itself (which for my taste is denied by nowadays behaviour of ln, but I'm no guru of Unix history and the answers, why certain decisions happened to be like they are). rm and ls for example behave different if applied to a symbolic link: Example 1: bash-2.03$ mkdir d1 bash-2.03$ ln -s d1 d2 bash-2.03$ ls -l total 1 drwxr-xr-x 2 foo bar 512 10 Jul 01:00 d1/ lrwxr-xr-x 1 foo bar 2 10 Jul 01:00 d2@ -> d1 bash-2.03$ rm d2/ rm: d2/: is a directory bash-2.03$ rm d2 bash-2.03$ ls -l total 1 drwxr-xr-x 2 foo bar 512 10 Jul 01:00 d1/ bash-2.03$ Example 2: bash-2.03$ mkdir d1 bash-2.03$ ln -s d1 d2 bash-2.03$ touch d2/f2 bash-2.03$ ls d2 d2@ bash-2.03$ ls d2/ f2 bash-2.03$ Example 3: bash-2.03$ mkdir d1 bash-2.03$ ln -s d1 d2 bash-2.03$ ls -l total 1 drwxr-xr-x 2 foo bar 512 10 Jul 01:26 d1/ lrwxr-xr-x 1 foo bar 2 10 Jul 01:26 d2@ -> d1 bash-2.03$ unlink d2/ unlink: d2/: is a directory bash-2.03$ unlink d2 bash-2.03$ ls -l total 1 drwxr-xr-x 2 coocoo coocoo 512 10 Jul 01:26 d1/ bash-2.03$ Excerpt from man unlink (man rm): When the utility is called as unlink, only one argument, which must not be a directory, may be supplied. No options may be supplied in this sim- ple mode of operation, which performs an unlink(2) operation on the passed argument. So d2 is not treated as directory, but rather as symbolic link. Summary: if d2 is a symbolic link, d2/ refers to the referenced directory whereas d2 (without slash) refers to the symbolic link itself. Shouldn't this be the same for ln? Ciao Siegbert To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message