Re: g_get_home_dir (), ${HOME}, and getpwuid ()->pw_dir

On Thu, Sep 27, 2012 at 9:35 AM, Colin Walters <walters verbum org> wrote:
> On Thu, 2012-09-27 at 12:42 +0700, Ivan Shmakov wrote:
>>     Gets the current user's home directory as defined in the password
>>     database.
>>     Note that in contrast to traditional UNIX tools, this function
>>     prefers passwd entries over the HOME environment variable.
> The question to answer is simple: why does GLib do what it does now?
> "git annotate" says the comment dates from:
> commit 5a866843df0d8dc5e5b81fcf2a8a572b6db31521
> Author: Matthias Clasen <mclasen redhat com>
> Date:   Wed Feb 2 06:07:14 2005 +0000
>     Move doc comments inline.
> Which is just moving around the original comment, so let's dig into
> that:
> $ git annotate 5a866843df0d8dc5e5b81fcf2a8a572b6db31521^ -- docs/reference/glib/tmpl/misc_utils.sgml
> Gives us:
> commit ea01de53feb47d592ba6401051ac85375e9a45a9
> Author: Matthias Clasen <matthiasc src gnome org>
> Date:   Thu Sep 9 14:06:20 2004 +0000
>     Clarify the relation of g_get_home_dir() and $HOME.
> So...yeah, not very enlightening =/  This kind of thing is a
> prime example of why I am constantly asking people to rewrite commit
> messages to say *WHY*, not what.

That commit was adding documentation. What else would you say there ?

The actual commit is

Tue Mar  5 00:38:54 2002  Owen Taylor  <otaylor redhat com>

        * glib/gutils.c (g_get_any_init): Where we have
        getpwuid[_r], use that in preference to $HOME, and
        only check $HOME as a fallback if getpwuid fails.

And the detailed analysis leading to this change is in

I don't think anything has changed there, really. And it is far too
late to change the behaviour of this function, a decade later.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]