bug-coreutils
[Top][All Lists]
Advanced

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

Re: why link when have ln


From: Jim Meyering
Subject: Re: why link when have ln
Date: Wed, 23 Jun 2004 10:39:02 +0200

Dan Jacobson <address@hidden> wrote:
> At least on the link and unlink Info pages, and probably also on their
> man pages, say why one would need them instead of ln and rm.

I don't know of any case in which one would prefer to use
link or unlink rather than ln or rm.  Does anyone else?
But POSIX does specify them.

I suppose there may be a use for unlink, at least on non-GNU systems:
if you want to remove something only if it's a non-directory,
with a single `unlink' syscall.  With `rm', on non-GNU systems
(where unlink may remove directories), rm must first stat the file,
and then -- if it's not a directory -- try to unlink it.  But that
takes two syscalls and leaves a small race condition: what if the
stat reports it is a file, but someone manages to replace that file
with a directory before the unlink call?

> Also saying
>    That makes it a little harder to remove files named `--help' and
>    `--version', so when the environment variable `POSIXLY_CORRECT' is set,
> is a tease, unless you mention using ./--help etc.

Thanks.  That's fixed in CVS:

  The @command{unlink} command honors the @option{--help} and
  @option{--version} options.  To remove a file whose name begins with
  @samp{-}, prefix the name with @samp{./}, e.g., @samp{unlink ./--help}.




reply via email to

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