import "fmt"
import "sys"

$tmpdir = sys.defaultenv("TMPDIR", "/tmp")

$x = sys.getenv("TEST")
$y = sys.getenv("DOESNOTEXIST")
$z = sys.getenv("EMPTY")

$a = sys.defaultenv("TEST", "321")
$b = sys.defaultenv("DOESNOTEXIST", "321")
$c = sys.defaultenv("EMPTY", "456")

$t = sys.hasenv("TEST")
$f = sys.hasenv("DOESNOTEXIST")

$env = sys.env()
$m = $env["TEST"] || "321"

file "${tmpdir}/environ" {
	state => $const.res.file.state.exists,
	content => fmt.printf("%s,%s,%s:%s,%s,%s:%t,%t:%s", $x, $y, $z, $a, $b, $c, $t, $f, $m),
}
