bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Difference in ln/ln -s semantics


From: Elmar Zander
Subject: Difference in ln/ln -s semantics
Date: Mon, 02 Feb 2009 09:51:21 +0100
User-agent: Thunderbird 2.0.0.19 (X11/20090105)

Hello,

as I've understood from those threads
  http://lists.gnu.org/archive/html/bug-coreutils/2007-12/msg00211.html
  http://lists.gnu.org/archive/html/bug-coreutils/2007-11/msg00006.html
and the FAQ the difference in ln and ln -s behaviour is intended and not 
fixable.

To summarize: if you type
* ln 'path1/file1' 'path2/file2', then 'path2/file2' points to './path1/file1', i.e. the path is considered relative to the current working directory (since the inode of 'path1/file1' is immediately resolved) * ln -s 'path1/file1' 'path2/file2', then 'path2/file2' points to 'path2/path1/file1', i.e. the path is considered relative to the directory where 'file2' resides (since just the string 'path1/file1' is stored somehow in 'path2/file2' and only resolved when the symlink 'path2/file2' is accessed)

If you know that in the first case 'file2' is made to point to the same inode and in the second case just the path 'path1/file1' is stored in 'file2' this behaviour is ok and understandable. *But*: the documentation (GNU coreutils 6.10, April 2008) for 'ln' just states for the -s option

‘-s’, ‘--symbolic’
    make symbolic links instead of hard links.

Nothing more. For me, a statement like this usually implies that the two are semantically equivalent (which they are not, as described). So, I think that the user should be informed of this difference, maybe by a sentence like

Note: if 'target' is a relative path and 'linkname' does not point to the current directory, the created link will be relative to the directory the link is created in.

or

  For semantic differences between ln and ln -s see the examples section.

and then some example like the above.

Regards,
Elmar




reply via email to

[Prev in Thread] Current Thread [Next in Thread]