get_variable


Description:

public unowned string? get_variable (string variable)

Returns the value of an environment variable.

On UNIX, the name and value are byte strings which might or might not be in some consistent character set and encoding. On Windows, they are in UTF-8. On Windows, in case the environment variable's value contains references to other environment variables, they are expanded.

Example: Get the value of an environment variable:

public static int main () {
// Local Output: ``fatal_criticals``
unowned string arg = Environment.get_variable ("G_DEBUG");
print ("%s\n", arg);
return 0;
}

valac --pkg glib-2.0 GLib.Environment.get_variable.vala

G_DEBUG=fatal_criticals ./GLib.Environment.get_variable

Parameters:

variable

the environment variable to get

Returns:

the value of the environment variable, or null if the environment variable is not found. The returned string may be overwritten by the next call to get_variable, set_variable or unset_variable.


Namespace: GLib.Environment
Package: glib-2.0