[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Symbolic link problem
From: |
Eric Blake |
Subject: |
Re: Symbolic link problem |
Date: |
Thu, 06 Dec 2007 13:08:00 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to NEWPORT Dennis on 12/6/2007 7:54 AM:
> mkdir targ
> ln -s targ src
> ll -rt
> ln -s targ src
>
> ll targ/
> total 0
> lrwxrwxrwx 1 cwbspr2 wbspr2 4 Dec 6 15:50 targ -> targ
>
> i.e. inside the targ directory you get a targ symlink to targ.
>
> This surely isn't the expected behaviour. Can anyone explain this ?
Actually, it IS expected behavior, as required by POSIX. If the final
argument can be resolved as a directory, then the link is created inside
that directory. Or, in other words, look at ln --help | head:
Usage: ln [OPTION]... [-T] TARGET LINK_NAME (1st form)
or: ln [OPTION]... TARGET (2nd form)
or: ln [OPTION]... TARGET... DIRECTORY (3rd form)
or: ln [OPTION]... -t DIRECTORY TARGET... (4th form)
In the 1st form, create a link to TARGET with the name LINK_NAME.
In the 2nd form, create a link to TARGET in the current directory.
In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.
Create hard links by default, symbolic links with --symbolic.
When creating hard links, each TARGET must exist.
In your case, the first attempt was of the 1st form, while the second
attempt is of the 3rd form. Use -T (a GNU extension, not available in all
ln implementations) to guarantee the first form.
> This message and any files transmitted with it are legally privileged
Please consider using a different email account when mailing to publicly
archived lists, since such disclaimers are unenforceable. Some people
refuse on principal to respond to such mails.
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHWFag84KuGfSFAYARAvLGAJ9/Smyhv3ySvnErhFokv6U1Fz24/gCdFVW5
2tqhWf7WdYPclf3+fIWwn9Q=
=R+j+
-----END PGP SIGNATURE-----