commit ef62452363de75240b21299e9f80b4851433faaa (tree) parent e98e5dda52d8bcaa2e59861bbbd500b81edfde2d Author: Jonathan Marler <johnnymarler@gmail.com> Date: Tue, 22 Oct 2019 23:21:16 -0600 Handle TERM=dumb for stdout/stderr Diffstat:
| M | lib/std/fs/file.zig | | | 12 | +++++++++++- |
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig @@ -177,7 +177,17 @@ pub const File = struct { if (windows.is_the_target) { return os.isCygwinPty(self.handle); } - return self.isTty(); + if (self.isTty()) { + if (self.handle == os.STDOUT_FILENO or self.handle == os.STDERR_FILENO) { + // Use getenvC to workaround https://github.com/ziglang/zig/issues/3511 + if (os.getenvC(c"TERM")) |term| { + if (std.mem.eql(u8, term, "dumb")) + return false; + } + } + return true; + } + return false; } pub const SeekError = os.SeekError;