| ... | @@ -1893,6 +1893,9 @@ pub fn execvpeZ( | ... | @@ -1893,6 +1893,9 @@ pub fn execvpeZ( |
| 1893 | /// Get an environment variable. | 1893 | /// Get an environment variable. |
| 1894 | /// See also `getenvZ`. | 1894 | /// See also `getenvZ`. |
| 1895 | pub fn getenv(key: []const u8) ?[:0]const u8 { | 1895 | pub fn getenv(key: []const u8) ?[:0]const u8 { |
| | 1896 | if (builtin.os.tag == .windows) { |
| | 1897 | @compileError("std.os.getenv is unavailable for Windows because environment strings are in WTF-16 format. See std.process.getEnvVarOwned for a cross-platform API or std.os.getenvW for a Windows-specific API."); |
| | 1898 | } |
| 1896 | if (builtin.link_libc) { | 1899 | if (builtin.link_libc) { |
| 1897 | var ptr = std.c.environ; | 1900 | var ptr = std.c.environ; |
| 1898 | while (ptr[0]) |line| : (ptr += 1) { | 1901 | while (ptr[0]) |line| : (ptr += 1) { |
| ... | @@ -1906,9 +1909,7 @@ pub fn getenv(key: []const u8) ?[:0]const u8 { | ... | @@ -1906,9 +1909,7 @@ pub fn getenv(key: []const u8) ?[:0]const u8 { |
| 1906 | } | 1909 | } |
| 1907 | return null; | 1910 | return null; |
| 1908 | } | 1911 | } |
| 1909 | if (builtin.os.tag == .windows) { | 1912 | if (builtin.os.tag == .wasi) { |
| 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."); | 1913 | @compileError("std.os.getenv is unavailable for WASI. See std.process.getEnvMap or std.process.getEnvVarOwned for a cross-platform API."); |
| 1913 | } | 1914 | } |
| 1914 | // The simplified start logic doesn't populate environ. | 1915 | // The simplified start logic doesn't populate environ. |