help-gnu-utils
[Top][All Lists]
Advanced

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

Re: symlink weirdness


From: Sam Holden
Subject: Re: symlink weirdness
Date: 14 Sep 2004 03:25:24 GMT
User-agent: slrn/0.9.8.0 (Linux)

On 13 Sep 2004 17:11:56 -0700, Roger Dahl <rdnews@dahlsys.com> wrote:
> If your current directory is A and you want to create a relative
> symlink to a file in directory B in directory C, you need to type the
> path as it would look from C, not from A.
>
> Though I understand that this makes 'ln' very simple (it just copies
> the argument into the link file), it doesn't make sense from a users
> perspective. When I'm in A, I can 'cp' from B to C without figuring
> out what the path to C will look like from B. 'cp -s' is even worse --
> it can only make links in the current directory.
>
> This oddity complicates writing scripts that create symlinks. We need
> more intelligent 'ln' and 'cp -s', that, given paths from A to B and
> from A to C can create links between B and C.
>
> Any thoughts?

If that was the case then how would I get the current behaviour for the
times that I want it.

I can get the behaviour you want with the current ln by doing
something like:

ln -s `pwd`/$B $C

(though it'd be better to to remove the /../ that might appear).

if ln did what you are suggesting then how would I get the current
behaviour of:

ln -s ../init.d/ssh /etc/rc0.d/K20ssh

(Note: I want the symlink to have '..' in it and my current directory is
not /etc/rc0.d).

Wouldn't a simple tool that takes two arguments a directory A and a path B
and outputs path C that is the same location as B from A. 

After all why should ln be special and have such logic when other tools
might also benefit. You'd use:

ln -s `relpath $C $B` $C


-- 
Sam Holden

reply via email to

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