Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Mar 2009 10:32:01 -0800 (PST)
From:      Nate Eldredge <neldredge@math.ucsd.edu>
To:        Andriy Gapon <avg@icyb.net.ua>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: ln: posixly confused
Message-ID:  <Pine.GSO.4.64.0903031029010.642@zeno.ucsd.edu>
In-Reply-To: <49AD73C8.7010500@icyb.net.ua>
References:  <49AD73C8.7010500@icyb.net.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
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



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