shithub: mc

ref: 4989e1b4e1184e1241c01d7d6f31a073d5a52a20
dir: /libstd/env.myr/

View raw version
use "extremum.use"
use "option.use"
use "sleq.use"

pkg std =
	extern var _environment	: byte[:][:]

	const getenv :	(name : byte[:] -> std.option(byte[:]))
;;

const getenv = {name
	var n
	for env in _environment
		n = min(name.len, env.len)
		if sleq(name, env[:n]) && sleq(env[n:n+1], "=")
			-> `Some env[n+1:]
		;;
	;;
	-> `None
}