From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 3 18:32:02 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E43D81065672 for ; Tue, 3 Mar 2009 18:32:02 +0000 (UTC) (envelope-from neldredge@math.ucsd.edu) Received: from euclid.ucsd.edu (euclid.ucsd.edu [132.239.145.52]) by mx1.freebsd.org (Postfix) with ESMTP id C6A4A8FC13 for ; Tue, 3 Mar 2009 18:32:02 +0000 (UTC) (envelope-from neldredge@math.ucsd.edu) Received: from zeno.ucsd.edu (zeno.ucsd.edu [132.239.145.22]) by euclid.ucsd.edu (8.11.7p3+Sun/8.11.7) with ESMTP id n23IW2o07506; Tue, 3 Mar 2009 10:32:02 -0800 (PST) Received: from localhost (neldredg@localhost) by zeno.ucsd.edu (8.11.7p3+Sun/8.11.7) with ESMTP id n23IW2q20639; Tue, 3 Mar 2009 10:32:02 -0800 (PST) X-Authentication-Warning: zeno.ucsd.edu: neldredg owned process doing -bs Date: Tue, 3 Mar 2009 10:32:01 -0800 (PST) From: Nate Eldredge X-X-Sender: neldredg@zeno.ucsd.edu To: Andriy Gapon In-Reply-To: <49AD73C8.7010500@icyb.net.ua> Message-ID: References: <49AD73C8.7010500@icyb.net.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-hackers@freebsd.org Subject: Re: ln: posixly confused X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Mar 2009 18:32:03 -0000 On Tue, 3 Mar 2009, Andriy Gapon wrote: > > Test case. > Preparation: > $ mkdir linktest > $ cd linktest > $ mkdir some_dir > $ mkdir other_dir > The test: > $ ln -s some_dir the_link > $ ln -s -f other_dir the_link > > Expected: the_link points to other_dir. > Actual result: some_dir contains symlink other_dir -> other_dir. > >> From ln(1): > SYNOPSIS > ln [-s [-F]] [-f | -iw] [-hnv] source_file [target_file] > ln [-s [-F]] [-f | -iw] [-hnv] source_file ... target_dir > > I thought that only true directory would trigger the second form. > I thought that the second argument being a symlink (to a file or to a directory) > should trigger the first form. > > I also read this: > http://www.opengroup.org/onlinepubs/009695399/utilities/ln.html > > I think that the text there (and in ln(1)) implies what I expected, but this is > not spelled out clearly. FWIW, Linux and Solaris have the same behavior as FreeBSD. The standard says the second form is triggered if the second argument "names an existing directory". An informative note in the symlink() specification at http://www.opengroup.org/onlinepubs/009695399/functions/symlink.html says "a symbolic link allows a file to have multiple logical names". Therefore, I think it's a fair interpretation to say that a symbolic link to an existing directory "names" it. -- Nate Eldredge neldredge@math.ucsd.edu