2af4a89e497d

fix: Switch color detection to std.Io.File.isTty (v3.0.12)

- Use stdout file TTY detection from std.Io instead of tcgetattr - Preserve NO_COLOR gating - Verify with build/test and TTY smoke run

time
2026-05-31 12:21 UTC · 4 months ago
machine
koh2
parent
139d763aea8c
4 files VERSION+1 −1build.zig.zon+1 −1src/main.zig+1 −1src/output.zig+2 −9
VERSION+1 −1
@@ -1 +1 @@1-3.0.111+3.0.12

view file

build.zig.zon+1 −1
@@ -9,7 +9,7 @@99     .name = .nina,1010     // This is a [Semantic Version](https://semver.org/).1111     // In a future version of Zig it will be used for package deduplication.12-    .version = "3.0.11",12+    .version = "3.0.12",1313     // Together with name, this represents a globally unique package1414     // identifier. This field is generated by the Zig toolchain when the1515     // package is first created, and then *never changes*. This allows

view file

src/main.zig+1 −1
@@ -31,7 +31,7 @@3131     // Initialize output module with buffered stdout writer3232     var stdout_buf: [16384]u8 = undefined;3333     var stdout_fw: Io.File.Writer = .init(.stdout(), io, &stdout_buf);34-    output.init(&stdout_fw.interface, startup.environ_map, true);34+    output.init(&stdout_fw.interface, io, startup.environ_map, true);3535     defer output.flush();3636 3737     const argv = try startup.minimal.args.toSlice(arena);

view file

src/output.zig+2 −9
@@ -44,18 +44,11 @@4444 var color_enabled: bool = true;4545 var teach_enabled: bool = false;4646 47-pub fn init(writer: *Io.Writer, environ: *const std.process.Environ.Map, color_config: bool) void {47+pub fn init(writer: *Io.Writer, io: std.Io, environ: *const std.process.Environ.Map, color_config: bool) void {4848     _w = writer;4949     color_enabled = color_config and50-        isStdoutTty() and50+        (std.Io.File.stdout().isTty(io) catch false) and5151         !environ.contains("NO_COLOR");52-}53-54-// libc-free tty check: tcgetattr fails with NotATerminal on a non-tty.55-// Avoiding std.c.isatty keeps the binary cross-compilable without libc.56-fn isStdoutTty() bool {57-    _ = std.posix.tcgetattr(std.posix.STDOUT_FILENO) catch return false;58-    return true;5952 }6053 6154 pub fn setTeach(enabled: bool) void {

view file