coreutils
[Top][All Lists]
Advanced

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

Re: Suggest on "ln"


From: Kaz Kylheku (Coreutils)
Subject: Re: Suggest on "ln"
Date: Mon, 19 Jul 2021 18:10:28 -0700
User-agent: Roundcube Webmail/0.9.2

On 2021-07-19 00:50, Patrick Reader wrote:
On 19/07/2021 08:48, Kamil Dudka wrote:
On Monday, July 19, 2021 2:29:18 AM CEST James Lu wrote:
"ln" should write a warning to stderr if the source file doesn't exist.
ln writes an error message to stderr if the source file does not exist:

$ mkdir new-dir
$ cd new-dir
$ ln does-not-exist target
ln: failed to access 'does-not-exist': No such file or directory

I'm guessing they meant `ln -s`.

Symbolic links with nonexistent targets are legitimate and useful.

They can be used to stash information that isn't intended to be
a pointer to an object in the file system at all:

   ln -sf "<insert hash here>" hash

A symlink is essentially a tiny text file where you can store
info, subject to some easy-to-meet restrictions.

Dangling links can be prepared in a file system structure that will
be installed somewhere, where the links will resolve:

  ln -sf /etc/alternatives/netcat $(DESTDIR)/bin/netcat

An option to emit a warning could be mildly useful, but it's
nothing you can't check yourself *after* the symlink is made:

  ln -sf $TARGET $LINK   # quoting elided for brevity

  [ -e $LINK ] || printf "warning: link target %s doesn't exist" $TARGET

Doing the check before the link is made is more involved because
a relative link target is resolved relative to the link's location.

Plus if it is buggy, then it won't match what the operating system
says; the ultimate arbiter of whether the link is dangling is
to create it and actually test it.




reply via email to

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