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 
internals.

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.

Regards,
 - Michael Pyne

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
xdg mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/xdg

Reply via email to