[gnu.utils.bug] Misleading comment in ln.c

bothner@CS.WISC.EDU (02/08/90)

This comment in fileutils-1.0/ln.c seems to misunderstand
the nature of symbolic links:

   This shares one problem with the 4.2BSD ln which is nearly
   impossible to remove in the general case: if you make symbolic links
   to multiple files where the target is a directory, you can lose.
   For example:

   % ln -s foo bar baz subdir
   % cat subdir/foo
   cat: subdir/foo: Too many levels of symbolic links
   % ls -l subdir
   total 3
   -rw-r--r--  1 mouse           3 Apr 10 17:46 foo -> foo
   -rw-r--r--  1 mouse           3 Apr 16 05:08 bar -> bar
   -rw-r--r--  1 mouse           3 Apr 19 03:34 baz -> baz

The problem has nothing to do with multiple files or directories
as targets.
% ln -s Makefile subdir/Makefile
% ls -l subdir
total 1
lrwxrwxr-x  1 bothner         8 Feb  7 12:21 Makefile@ -> Makefile

The same thing happens with both GNU ln, and /bin/ln (on a DECstation 3100).
The "problem" is that the symlink system call does not interpret
the old name, it just copies it into the new symbolic-link file. 
One solution is to use absolute path-names:
% ln -s $PWD/Makefile subdir
% ls -l subdir
total 1
lrwxrwxr-x  1 bothner        40 Feb  7 12:31 Makefile@ -> /var/home/bothner/file
	--Per Bothner