Convention Over Configuration: A Way Forward?

Michael Pyne mpyne at
Wed Jan 18 14:43:55 PST 2012

On Wednesday, January 18, 2012 11:04:44 Nicolas Mailhot wrote:
> Le Lun 9 janvier 2012 13:53, Kevin Krammer a écrit :
> > Right, I didn't consider that they already have to read an environment
> > variable.
> > But maybe they consider $HOME to be always set or only explicitly unset,
> > i.e. always just do
> > config_path = getenv( "HOME" ) + config_name
> They don't have to read an env variable for $HOME they can just use ~.

That doesn't always work. Normally shells expand out the value of ~/ to be the 
correct home directory before a program ever sees it, but ~/ does not work for 
the underlying system calls. So, you should not use ~/ in a program's 

It gets worse though... ~/ doesn't necessarily expand out to $HOME, instead it 
should be based on the user's home directory as given by the getpwent(3) and 
similar library calls. $HOME being set correctly at all is yet another thing 
that the shell is typically "nice" about so you can usually rely on it but 
depending on how sensitive your code is you should not rely on that.

 - Michael Pyne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the xdg mailing list