GNOME Bugzilla – Bug 394687
g_get_home_dir documentation confusing
Last modified: 2007-01-12 17:56:00 UTC
This bug was submitted to the Debian BTS: > The documentation for g_get_home_dir specifies: > > | G_CONST_RETURN gchar* g_get_home_dir (void); > | > | Gets the current user's home directory. > | > | Note that in contrast to traditional Unix tools, this function > | prefers passwd entries over the HOME environment variable. > | > | Returns : the current user's home directory. > > Which is obvious self-contradicting, as the home directory is the > content of the HOME environment variable, and the passwd entry is > only one possible initial value (if it exists at all). > > As the comment seems to indicate that it does not return the > home directory, it should rather read something like: > > Gets the current user's possible initial home directory. > > Note that the actual home directory for this program can be > get by reading the HOME environment variable, this is only a > value which was most likely used by the login program to > initial set it. > > Returns : the current user's most likely initial home directory. I think the submitter is right - usual *ix practice is to consider the value of $HOME to be the home directory, so the current documentation is a bit confusing if you're just skimming through the documentation. TIA, Marc
There is a long historical discussion about this, unfortunately I think it was very old and I have no idea what forum it may have been in. To the extent I remember it, HOME was causing all sorts of problems when running a program as another user (e.g. with pam_console or su) and the reason g_get_home_dir works the way it does is that most apps should use the g_get_home_dir value in preference to HOME. The docs might should say "gets the home directory your application should use" Anyway, all I really remember is that this was done on purpose many years ago and it fixed a lot of bugs at that time, so changing it back or not using this function would probably break something.
I'm really not asking for a code change, that would break all sorts of applications and is really not needed. Updating the documentation would be nice, to point out that unexpected behaviour.
2007-01-12 Matthias Clasen <mclasen@redhat.com> * glib/gutils.c (g_get_home_dir): Clarify docs. (#394687, Marc Brockschmidt)