os: implement os.ExpandEnv

This commit is contained in:
Dan Kegel
2022-01-16 03:20:05 +00:00
committed by Ron Evans
parent 94b075e423
commit db0efc52c7
4 changed files with 292 additions and 9 deletions
+13
View File
@@ -147,6 +147,19 @@ func Getenv(key string) (value string, found bool) {
}
func Setenv(key, val string) (err error) {
if len(key) == 0 {
return EINVAL
}
for i := 0; i < len(key); i++ {
if key[i] == '=' || key[i] == 0 {
return EINVAL
}
}
for i := 0; i < len(val); i++ {
if val[i] == 0 {
return EINVAL
}
}
keydata := cstring(key)
valdata := cstring(val)
errCode := libc_setenv(&keydata[0], &valdata[0], 1)