[buug] ln -sf bug
Jon McClintock
jammer at weak.org
Fri Aug 6 15:26:14 PDT 2004
On Fri, Aug 06, 2004 at 03:12:23PM -0700, Stefan Lasiewski wrote:
> I think it will remove destination files, but not destination directories.
>
> While this may violate the principal of least suprises, I think it's designed
> that so you don't accidently blow away an active symlink. ... or something
Someone else already posted this, but what you really want is '-n'
(--no-dereference); that way, it won't dereference the target if it's a
symbolic link.
So,
ln -snf linux-2.6.7 linux
Will do the right thing, even if there is already a 'linux' symlink. It
won't, however, remove 'linux' if it's a real directory. As someone else
pointed out, it will instead create a symbolic link inside the target
directory with the same name as the source.
The truth is in the man page, it just must be ferreted out:
SYNOPSIS
ln [OPTION]... TARGET [LINK_NAME]
ln [OPTION]... TARGET... DIRECTORY
ln [OPTION]... --target-directory=DIRECTORY TARGET...
[...cut...]
tory. When using the second form with more than one TAR
GET, the last argument must be a directory; create links
in DIRECTORY to each TARGET.
(Note that is doesn't say that "more than one TARGET" is necessary to invoke
the second form.)
-f, --force
remove existing destination files
(Note that it doesn't say anything about directories. Infer thusly that
passing a directory as the last parameter will invoke the "second form".)
-n, --no-dereference
treat destination that is a symlink to a directory
as if it were a normal file
(Here's the option you want. Treat symlinks to directories as files, for
the purpose of --force'ing their deletion.)
Interpreting man pages is indeed an art.
-Jon
More information about the buug
mailing list