Search code examples
javascriptlinuxenvironment-variablesxulxulrunner

In xul, how to retrieve an environment variable?


I have an environment called $REP, how can I access the value of this variable using Xulrunner in a Linux environment?

--udpate

attempting with nslEnvironment:

var env = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);
dump("bash=" + env.exists("BASH") + '\n');
dump("bash=" + env.exists("$BASH") + '\n');

the output was:

bash=false
bash=false

as you imagine, it should output "/bin/bash" as it does in the terminal. I also tried using get to see if it was just the exists method wrong, but it returned empty.

What can be wrong here?


Solution

  • Use nsIEnvironment to read (and set) environment variables.