g_get_home_dir(): honour $HOME
authorRyan Lortie <desrt@desrt.ca>
Sun, 2 Dec 2012 17:07:24 +0000 (12:07 -0500)
committerRyan Lortie <desrt@desrt.ca>
Thu, 6 Dec 2012 16:41:46 +0000 (11:41 -0500)
commit7523c04b54485f3343a3fb55ada4a8f3d8290860
tree04d30121e38610044b057abff0e15424fa7a05a5
parent28f88cf111eb0c8ac109d8a99560c39eaa71ce01
g_get_home_dir(): honour $HOME

If the $HOME environment variable is set, prefer that to the entry in
/etc/passwd.

This brings us in line with almost every other utility and library on
UNIX-like systems while avoiding some of the more complicated
possibilities that have been suggested.

This incompatible change has been petitioned for quite some time by
many, and in particular from the Debian world, which carries a patch
that adds a new G_HOME environment variable with the same meaning as
this patch now assigns to HOME.

The primary motivation for the change was to increase the testability of
GLib-based programs from 'make check' types of frameworks: it is now
possible to set HOME to a temp directory to avoid the testsuite
modifying the user's real home directory.

The change also brings us increased compliance with the XDG Base
Directory Specification.  The specification specifically states that the
default values should be computed based on the HOME environment
variable, whereas we were basing them on the value from /etc/passwd.

The change was agreed to by all in attendence at the November 29 Gtk+
developer meeting.

https://bugzilla.gnome.org/show_bug.cgi?id=142568
NEWS
glib/gutils.c