Skip to content

Commit ef62452

Browse files
marler8997andrewrk
authored andcommitted
Handle TERM=dumb for stdout/stderr
1 parent e98e5dd commit ef62452

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/std/fs/file.zig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,17 @@ pub const File = struct {
177177
if (windows.is_the_target) {
178178
return os.isCygwinPty(self.handle);
179179
}
180-
return self.isTty();
180+
if (self.isTty()) {
181+
if (self.handle == os.STDOUT_FILENO or self.handle == os.STDERR_FILENO) {
182+
// Use getenvC to workaround https://github.com/ziglang/zig/issues/3511
183+
if (os.getenvC(c"TERM")) |term| {
184+
if (std.mem.eql(u8, term, "dumb"))
185+
return false;
186+
}
187+
}
188+
return true;
189+
}
190+
return false;
181191
}
182192

183193
pub const SeekError = os.SeekError;

0 commit comments

Comments
 (0)