Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access environment variables in Vala?

How do I access environment variables in Vala? (as above) it seems simple, but I can't find how g_getenv() is mapped into Vala.

like image 334
kaStevie Avatar asked Dec 21 '10 01:12

kaStevie


People also ask

How do you view environment variables?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables.

How do I get a list of environment variables?

To list all the environment variables, use the command " env " (or " printenv "). You could also use " set " to list all the variables, including all local variables.

How do I know where my environment variable is set?

On Windows In the command window that opens, enter echo %VARIABLE%. Replace VARIABLE with the name of the environment variable you set earlier. For example, to check if MARI_CACHE is set, enter echo %MARI_CACHE%. If the variable is set, its value is displayed in the command window.

How do you get all environment variables and how can you use them?

The most used command to displays the environment variables is printenv . If the name of the variable is passed as an argument to the command, only the value of that variable is displayed. If no argument is specified, printenv prints a list of all environment variables, one variable per line.


1 Answers

The answer lies in the bindings file. Vala uses bindings (in .vapi files) for binding its constructs to the C language. In this case you can grep through glib-2.0.vapi (on my system that is in /usr/share/vala-0.10/vapi), and you'll see that it is bound as:

unowned string? GLib.Environment.get_variable(string name)

It can be quite useful to have the location of the core VAPI files handy, because if you know the C name of a function you can just grep for it.

like image 122
Michael Trausch Avatar answered Sep 30 '22 11:09

Michael Trausch