Subject: Re: bug#7634: anomaly ln command

From: Bob Proulx <[email-masked]>
Date: Mon, 13 Dec 2010 10:06:23 -0700

Baggia Nate wrote:
> work with Fedora (version 14) and I noticed that the command:
> 
> *ln -fs /path/from /path/to*
> 
> does not actually remove the target path.

That is intentional behavior.  This is because that is what BSD does
and BSD created the ln command.  The GNU ln follows the BSD ln
behavior.  This gets discussed every so often and the archives will
have a much longer discussion of it.

> In my case the */path/to* correspond to another symbolic link
> (*/path/other* ).  Why not work even if given the option *-f*
> (*--force*) flag?

If you are used to the System V behavior then this will be a
difference.  SysV ln always behaves as if the -n option has been
given.  The only portable way to deal with differences between SysV
and BSD behaviors is to remove the target symlink before creating the
new one.

  rm -f /path/to
  ln -sf /path/from /path/to

The BSD (and therefore GNU) expectation would be to use the -n
option.  But SysV does not support the -n option.  But if you are not
concerned about portability to SysV then that is the easiest way.

  ln -sfn /path/from /path/to

Since this is intentional behavior I am closing the bug.  But feel
free to continue the discussion if more information, clarification or
discussion is needed.

Bob