User: Password:
|
|
Subscribe / Log in / New account

Empty symlinks and full POSIX compliance

Empty symlinks and full POSIX compliance

Posted Jun 13, 2013 18:42 UTC (Thu) by dmuc (guest, #91417)
Parent article: Empty symlinks and full POSIX compliance

Empty symlink targets are not stupid.

Years ago we run a software which was configured with a lot of symlinks, and a few plain files.

It worked like that:

/etc/foo/mail/to -> foo@example.com
/etc/foo/mail/subject-prefix ->

The benefit is: You don't need a config file parser, you can access the config simply by readlink("/etc/foo/mail/subject-prefix").

With an empty symlink you have another value you can use. Think of NULL vs "" in SQL.

file not found -> NULL
symlink to "" -> ""
symlink to "x" -> "x"

The semantic for subject-prefix was: if the symlink is not there, there was a default for subject-prefix. If you want no prefix, just set the symlink to "".


(Log in to post comments)

Empty symlinks and full POSIX compliance

Posted Jun 14, 2013 0:31 UTC (Fri) by mpr22 (subscriber, #60784) [Link]

An amusing hack, but ln makes a lousy configuration editor.


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