| author | |
| committer | |
| log | 69982339ed3c35df890f205fada0bb5772abdb63 |
| tree | b736d6b26a3fd2afab4721f5783b0bbda2f36839 |
| parent | 742030a8f27190ce36fd7b240c2def6774dfdb63 |
`std.process.getEnvMap` or `std.process.getEnvVarOwned` should be used
instead, requiring allocation.3 files changed, 8 insertions(+), 1 deletions(-)
lib/std/os.zig+2| ... | ... | @@ -1908,6 +1908,8 @@ pub fn getenv(key: []const u8) ?[:0]const u8 { |
| 1908 | 1908 | } |
| 1909 | 1909 | if (builtin.os.tag == .windows) { |
| 1910 | 1910 | @compileError("std.os.getenv is unavailable for Windows because environment string is in WTF-16 format. See std.process.getEnvVarOwned for cross-platform API or std.os.getenvW for Windows-specific API."); |
| 1911 | } else if (builtin.os.tag == .wasi) { | |
| 1912 | @compileError("std.os.getenv is unavailable for WASI. See std.process.getEnvMap or std.process.getEnvVarOwned for a cross-platform API."); | |
| 1911 | 1913 | } |
| 1912 | 1914 | // The simplified start logic doesn't populate environ. |
| 1913 | 1915 | if (std.start.simplified_logic) return null; |
lib/std/os/test.zig+5| ... | ... | @@ -660,6 +660,11 @@ test "mmap" { |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | test "getenv" { |
| 663 | if (native_os == .wasi and !builtin.link_libc) { | |
| 664 | // std.os.getenv is not supported on WASI due to the need of allocation | |
| 665 | return error.SkipZigTest; | |
| 666 | } | |
| 667 | ||
| 663 | 668 | if (native_os == .windows) { |
| 664 | 669 | try expect(os.getenvW(&[_:0]u16{ 'B', 'O', 'G', 'U', 'S', 0x11, 0x22, 0x33, 0x44, 0x55 }) == null); |
| 665 | 670 | } else { |
lib/std/zig/system/NativePaths.zig+1-1| ... | ... | @@ -100,7 +100,7 @@ pub fn detect(arena: Allocator, native_info: NativeTargetInfo) !NativePaths { |
| 100 | 100 | return self; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | if (builtin.os.tag != .windows) { | |
| 103 | if (builtin.os.tag != .windows and builtin.os.tag != .wasi) { | |
| 104 | 104 | const triple = try native_target.linuxTriple(arena); |
| 105 | 105 | |
| 106 | 106 | const qual = native_target.ptrBitWidth(); |