ln: posixly confused

Andriy Gapon avg at icyb.net.ua
Tue Mar 3 10:15:42 PST 2009


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.

I am confused.

-- 
Andriy Gapon


More information about the freebsd-hackers mailing list