After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 394687 - g_get_home_dir documentation confusing
g_get_home_dir documentation confusing
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: docs
2.12.x
Other Linux
: Normal minor
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2007-01-09 16:23 UTC by Marc Brockschmidt
Modified: 2007-01-12 17:56 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Marc Brockschmidt 2007-01-09 16:23:22 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
Comment 1 Havoc Pennington 2007-01-09 16:35:46 UTC
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.
Comment 2 Marc Brockschmidt 2007-01-09 17:03:31 UTC
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.
Comment 3 Matthias Clasen 2007-01-12 17:56:00 UTC
2007-01-12  Matthias Clasen  <mclasen@redhat.com>

        * glib/gutils.c (g_get_home_dir): Clarify docs.  (#394687,
        Marc Brockschmidt)