I think that was an intention.
I will repeat citation from here, sorry:
Shells for instance, map environment variables to shell variables and are likely not to use putenv/setenv libc functions
I think that was an intention.
I will repeat citation from here, sorry:
Shells for instance, map environment variables to shell variables and are likely not to use putenv/setenv libc functions
I came across this interesting recent post about thread safety of setenv, which might be worth considering: Setenv is not Thread Safe and C Doesn't Want to Fix It (evanjones.ca)
FWIW I’m +1 on having a setenv function available - although env vars can cause gotchas and hidden behaviour changes, in some cases it’s a sensible/practical tool.
Zig does map the environ
variable to std.c.environ
, so you could write your own function to modify it. Or you can link libc and add your own extern to use it:
extern fn putenv(string: [*:0]u8) c_int;
If you want it to be included in the standard library, then perhaps an issue should be made on the Ziglang git repo?