View source code
Display the source code in std/process.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.process.environment.get
Retrieves the value of the environment variable with the given ,
or a default value if the variable doesn't exist.
name
Unlike environment.opIndex, this function never throws.
auto sh = environment.get("SHELL", "/bin/sh");
This function is also useful in checking for the existence of an
environment variable.
auto myVar = environment.get("MYVAR");
if (myVar is null)
{
// Environment variable doesn't exist.
// Note that we have to use 'is' for the comparison, since
// myVar == null is also true if the variable exists but is
// empty.
}
Prototype
static string get( const(char[]) name, string defaultValue = null ) @safe;
Throws
std.utf.UTFException if the variable contains invalid UTF-16
characters (Windows only).
Authors
Lars Tandle Kyllingstad, Steven Schveighoffer, Vladimir Panteleev