diff options
| author | Brendan Burns <bburns@microsoft.com> | 2023-01-06 08:40:16 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-06 18:40:16 +0200 |
| commit | 24b4e643f486ce803f758a6eab0c587c44b9cfa4 (patch) | |
| tree | a462fbd4199453da809cb7239ed52bb81e26c8cc /lib/std/debug.zig | |
| parent | 7a2d7ff6280c4e75618b5d4de24c3ff4aedd8a18 (diff) | |
| download | zig-24b4e643f486ce803f758a6eab0c587c44b9cfa4.tar.gz zig-24b4e643f486ce803f758a6eab0c587c44b9cfa4.zip | |
Implement some more environment functions for WASI.
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 44310de261..983d088374 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -110,27 +110,28 @@ pub fn getSelfDebugInfo() !*DebugInfo { } pub fn detectTTYConfig(file: std.fs.File) TTY.Config { - if (process.hasEnvVarConstant("ZIG_DEBUG_COLOR")) { + if (builtin.os.tag == .wasi) { + // Per https://github.com/WebAssembly/WASI/issues/162 ANSI codes + // aren't currently supported. + return .no_color; + } else if (process.hasEnvVarConstant("ZIG_DEBUG_COLOR")) { return .escape_codes; } else if (process.hasEnvVarConstant("NO_COLOR")) { return .no_color; - } else { - if (file.supportsAnsiEscapeCodes()) { - return .escape_codes; - } else if (native_os == .windows and file.isTty()) { - var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined; - if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) { - // TODO: Should this return an error instead? - return .no_color; - } - return .{ .windows_api = .{ - .handle = file.handle, - .reset_attributes = info.wAttributes, - } }; - } else { + } else if (file.supportsAnsiEscapeCodes()) { + return .escape_codes; + } else if (native_os == .windows and file.isTty()) { + var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined; + if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) { + // TODO: Should this return an error instead? return .no_color; } + return .{ .windows_api = .{ + .handle = file.handle, + .reset_attributes = info.wAttributes, + } }; } + return .no_color; } /// Tries to print the current stack trace to stderr, unbuffered, and ignores any error returned. |
