Change function calls to the correct one, remove extra argument in getenv call, and fix typo.
24 lines
569 B
Plaintext
24 lines
569 B
Plaintext
# read and print environment variable
|
|
# env TEST=123 EMPTY= ./mgmt run --tmp-prefix --converged-timeout=5 lang examples/lang/env0.mcl
|
|
|
|
import "fmt"
|
|
import "sys"
|
|
|
|
$x = sys.getenv("TEST")
|
|
|
|
print "print1" {
|
|
msg => fmt.printf("the value of the environment variable TEST is: %s", $x),
|
|
}
|
|
|
|
$y = sys.defaultenv("DOESNOTEXIT", "321")
|
|
|
|
print "print2" {
|
|
msg => fmt.printf("environment variable DOESNOTEXIT does not exist, defaulting to: %s", $y),
|
|
}
|
|
|
|
$z = sys.defaultenv("EMPTY", "456")
|
|
|
|
print "print3" {
|
|
msg => fmt.printf("same goes for empty variables like EMPTY: %s", $z),
|
|
}
|