Task

Show how to get one of your process's environment variables.

The available variables vary by system;   some of the common ones available on Unix include:

   PATH
   HOME
   USER


#!/usr/bin/lasso9
 
define getenv(sysvar::string) => {
	local(regexp = regexp(
		-find = `(?m)^` + #sysvar + `=(.*?)$`,
		-input = sys_environ -> join('\n'),
		-ignorecase
	))
	return #regexp ->find ? #regexp -> matchString(1)
}
 
stdoutnl(getenv('HOME'))
stdoutnl(getenv('PATH'))
stdoutnl(getenv('USER'))
stdoutnl(getenv('WHAT'))