Import std.os.env
std.os.env
Env, the environment's variables, which the program starts with and passes on to what it starts: Get, Set, Unset, All, and Expand, which any thread can use, and Load, which sets those a .env file names.
std/os/env.fb
Types
Env
struct
Public Struct Env
Env's Static Methods.
-
The variable
name's value, or Null when it isn't set. On Windows a name is the same in any case, so "Path" is "PATH". -
Sets the variable
nametovalue. Panics whennameis empty or has an '=' or a NUL, orvaluehas a NUL, which no variable can. -
Removes the variable
name, when it's set. Panics whennamecan't be a variable's, as Set does. -
Every variable, by its name.
-
textwith each $NAME and ${NAME} in it given its variable's value, or "" when it isn't set, and each $$ given as one '$'. A name is a letter or '', then letters, digits, and ''s, as long as it goes, and any other '$' stays as it is. -
Public Static Method Load(path: Path, replace: Bool = False) Throws IOError, ParseErrorstatic method #Sets the variables the .env file at
pathnames, each in a line of its own, as NAME=value, with "export " before it or not, and blanks around the '=' or not. A line that's blank or starts with '#' is skipped. A value in 's is as it is, and one in "s can hold \n, \r, \t, ", \, and $, and both can go on over lines; one without them ends at its line's end, or at a '#' at its start or after a blank, which starts a comment, without the blanks before it. Only a comment can follow a quoted one. A value that isn't in 's is Expanded, its $NAMEs given what's set, the lines before it included. A variable that's already set is left as it is, unlessreplaceis True; one the file names again takes its last value. Throws an IOError when the file can't be read, and a ParseError, with its line and column, for a line that isn't one of these, a quote that isn't closed, a ${ without a name and '}', or a value with a NUL, before any variable is set.
Report an issue with this page or with FutureBlitz on GitHub.