|
|
Log in / Subscribe / Register

Empty symlinks and full POSIX compliance

Empty symlinks and full POSIX compliance

Posted Jun 2, 2013 0:40 UTC (Sun) by yeti-dn (guest, #46560)
In reply to: Empty symlinks and full POSIX compliance by rgmoore
Parent article: Empty symlinks and full POSIX compliance

Certainly it can be argued that the POSIX-specified behaviour is stupid. But the same holds for the Linux behaviour. Giving `no such file or directory' for a symlink target -- what is more odd and confusing than that?

So the question is not whether to change nice Linux behaviour to stupid POSIX behaviour, but whether to swap one kind of stupid behaviour for another. If one of them is standard-compliant it should be the clear winner.


to post comments

Empty symlinks and full POSIX compliance

Posted Jun 3, 2013 8:53 UTC (Mon) by micka (subscriber, #38720) [Link]

I'm not sure I agree that a change TO a stupid behaviour is a good idea, event if the current state is a stupid behaviour and the next state is standard-compliant.

The change is just not worth it, and if you must have a stupid behaviour, it's better to keep the one you have.

It would be different to change to a *less* stupid behaviour (even non standard-compliant) like changing the 'no such file or directory' to 'symlink to empty name not allowed'. Not compliant but sure less stupid and confusing.

Empty symlinks and full POSIX compliance

Posted Jul 20, 2013 1:49 UTC (Sat) by kirv (guest, #89016) [Link]

Bingo. As the originator of this 'bug report', the reason I posted it was that the error message was confusing. Consider:

$ ln -s /no-such-file foo
$ ln -s "" bar
ln: creating symbolic link `bar' -> `': No such file or directory

Since the non-existence of the target file is not a problem, what 'file or directory' is being referred to?

I have no particular use in mind for empty symlink targets, and just ran into this case while working up some test scripts. I do have use for arbitrary strings in the system target, and would think it preferable to allow the empty string there just for consistency, but at least the error message should be meaningful.

The whole POSIX question is beyond me, but I don't think any special handling should be necessary for empty symlinks. Just let them resolve as they are, e.g., so maybe cat bar or ls bar would look like:

$ cat ""
cat: : No such file or directory
$ ls ""
ls: cannot access : No such file or directory


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds