[Top][All Lists]

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

Re: Bug or feature? replace symlink to directory with ln -fs does not wo

From: Bob Proulx
Subject: Re: Bug or feature? replace symlink to directory with ln -fs does not work
Date: Mon, 23 May 2005 20:43:17 -0600
User-agent: Mutt/1.5.9i

Peter Kratzer <address@hidden> writes:
> Contrary to the Unix behaviour (e.g. HP-UX) using this command on a
> GNU/Linux system does not replace the link, but creates a new link in the
> originally referenced directory.

This has appeared as a portability problem a number of times in the
past.  If there is any possibility of having a symlink to a directory
then the only portable solution is to remove symlinks before creating
them.  This is the only solution for HP-UX.  It works compatibly on
GNU systems.

  rm -f target
  ln -s source target

Paul Eggert wrote:
> Actually, HP-UX is the odd man out here.  GNU "ln" is compatible
> with Solaris (at least Solaris 10, which I just checked).

My understanding is that BSD uses ln -sfn or ln -sfh but then notes in
theirs docs that -n and -h are non-portable and "provided solely for
compatibilty with other ln implementations."  I have no idea what
other implementations they are referring.

SysV however has never had that option.  HP-UX is SysV-like so HP-UX
does not have the option.  I don't know anything about Solaris here.

I just checked AIX and the AIX ln only supports -s and -f too.

> And POSIX requires the GNU and Solaris behavior.

Can you cite the reference?  I could not find it here:


Only -s and -f are required.  Has that publication been superseded?

> Perhaps you can file a bug report with HP.

I do not believe it is a standard option and therefore HP-UX is not
required to support it.

> Recent versions of GNU "ln" support an option -T that should do what
> you want, e.g., "ln -fsT dir.1 dirlink".  Older versions have an -n
> option that should also work.  These options are all POSIX extensions,
> though, so they might not be portable to HP-UX.

Can you provide a reference to the standards on -T?  In any case, it
seems to be a new option and so would not seem portable in any
practical sense.


reply via email to

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