Symbolic links
2008-09-15 14:40![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
What happens if you try to create a symlink to a zero-length target, as in ln -s "" foo?
Linux: ENOENT.
Mac OS X 10.4: EINVAL.
FreeBSD: works, and any attempt to resolve the symlink returns ENOENT.
Solaris: works, and the resulting symlink behaves the same as ln -s . foo
no subject
Date: 2008-09-15 15:46 (UTC)NetBSD: As FreeBSD
no subject
Date: 2008-09-15 15:55 (UTC)no subject
Date: 2008-09-15 16:06 (UTC)I think the relevant sentence is:
Which implies that FreeBSD and Solaris are correct to create the symlink and the others do not conform to POSIX. The pathname resolution algorithm explains how to interpret symlinks, and it is described in terms of string concatenation in a way that agrees with Solaris not FreeBSD. On the other hand my intuition agrees with FreeBSD.
no subject
Date: 2008-09-15 15:56 (UTC)no subject
Date: 2008-09-15 16:31 (UTC)no subject
Date: 2008-09-15 16:46 (UTC)strace ln -s "" zzz
turns up so it doesn't look as ifglibc
is doing anything obviously silly above the syscall level.no subject
Date: 2008-09-15 16:57 (UTC)no subject
Date: 2008-09-15 20:10 (UTC)no subject
Date: 2008-09-15 20:14 (UTC)$ pwd
/tmp/foo
$ cd ""
$ set -P
$ cd ""
bash: cd: : No such file or directory
But really this is caused by the same disagreement. Bash is behaving as I would expect and assuming chdir("") is a noop. But Linux apparently gives an error.
no subject
Date: 2008-09-15 20:16 (UTC)What an abomination, I wonder why I haven't turned it off yet.