Search This Blog

Saturday, August 10, 2019

Accessing environment variables

If you previously wrote any type of script you probably, sooner or later, want to access environment variables. OpenAF is no different and access to the operating system environment variables it's very easy with getEnv and getEnvs functions:
> getEnvs()
{
   "PATH": "/some/dir:/usr/bin",
   "SHELL": "/bin/bash",
   "CUSTOM": "something",
//...
getEnvs will retrieve a map of the current environment variables. To retrieve a specific environment variable you can directly access the map:
> getEnvs()["CUSTOM"]
"something"
or use getEnv directly:
> getEnv("CUSTOM")
"something"

No comments:

Post a Comment

Using arrays with parallel

OpenAF is a mix of Javascript and Java, but "pure" javascript isn't "thread-safe" in the Java world. Nevertheless be...