diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-11-27 12:35:52 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-11-27 12:35:52 -0500 |
| commit | 8b897851facaa177e2346e0d97fcba7411dfc0aa (patch) | |
| tree | f2f3ef96a5628ec4d76c4097ef7c26a85f1d855a /src/stdlib/stdlib.c | |
| parent | 31c47caa0282cbdf43361a3c0f45fff9699a8814 (diff) | |
Update `setenv()` to take an optional value, also bugfix for `setenv()`
returning a value.
Diffstat (limited to 'src/stdlib/stdlib.c')
| -rw-r--r-- | src/stdlib/stdlib.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/stdlib/stdlib.c b/src/stdlib/stdlib.c index 21547efe..8ec9e90b 100644 --- a/src/stdlib/stdlib.c +++ b/src/stdlib/stdlib.c @@ -219,7 +219,10 @@ OptionalText_t getenv_text(Text_t name) { } public -void setenv_text(Text_t name, Text_t value) { setenv(Text$as_c_string(name), Text$as_c_string(value), 1); } +void setenv_text(Text_t name, OptionalText_t value) { + if (value.tag == TEXT_NONE) unsetenv(Text$as_c_string(name)); + else setenv(Text$as_c_string(name), Text$as_c_string(value), 1); +} typedef struct cleanup_s { Closure_t cleanup_fn; |
