Qu

getenv

Builtin index · File I/O

result = getenv(name)

Input: name · Output: result

What it is

Reads one environment variable. name (string) is the variable's name.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = getenv(name)
name stringnot documented yet
result string
Returns its value as a string, or none if it isn't set — so getenv("HOME") ?? "/tmp" is the idiom for a default.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

args = argv()
print(length(args))                      # 2 -- "data.csv" and "1000"

print(args)                              # ("data.csv", "1000")


level = getenv("QU_LOG") ?? "info"
print(level)
output
0
()
info

from file-io

How it works

getenv(name) -- Nothing when unset rather than "", so an unset variable and one set to the empty string stay distinguishable, and it composes with ??: level = getenv("QU_LOG") ?? "info"

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.