[ Version ( since = "2.28" ) ]
[ CCode ( array_length = false , array_null_terminated = true , cname = "g_get_environ" ) ]
public string[] @get ()

Gets the list of environment variables for the current process.

The list is null terminated and each item in the list is of the form 'NAME=VALUE'.

This is equivalent to direct access to the 'environ' global variable, except portable.

The return value is freshly allocated and it should be freed with strfreev when it is no longer needed.

Example: List all environment variables:

public static int main (string[] args) {
// Output:
// ...
string[] vars = Environ.get ();
foreach (unowned string str in vars) {
print ("%s\n", str);
return 0;

valac --pkg glib-2.0 GLib.Environ.get.vala


the list of environment variables

Namespace: GLib.Environ
Package: glib-2.0