c22879cea5ce

replace std.c.isatty with libc-free tcgetattr tty check so nina cross-compiles static for linux

time
2026-05-29 03:12 UTC · 4 months ago
machine
koh2
parent
849133ec5fac
2 files src/output.zig+8 −1zig-out-linux/bin/ninalarge
src/output.zig+8 −1
@@ -46,8 +46,15 @@4646 pub fn init(writer: *Io.Writer, environ: *const std.process.Environ.Map, color_config: bool) void {4747     _w = writer;4848     color_enabled = color_config and49-        (std.c.isatty(std.posix.STDOUT_FILENO) != 0) and49+        isStdoutTty() and5050         !environ.contains("NO_COLOR");51+}52+53+// libc-free tty check: tcgetattr fails with NotATerminal on a non-tty.54+// Avoiding std.c.isatty keeps the binary cross-compilable without libc.55+fn isStdoutTty() bool {56+    _ = std.posix.tcgetattr(std.posix.STDOUT_FILENO) catch return false;57+    return true;5158 }5259 5360 pub fn setTeach(enabled: bool) void {

view file

zig-out-linux/bin/ninalarge

over 1 MB, not shown

view file