diff --git a/src/main.zig b/src/main.zig index e864ae4..d8054fb 100644 --- a/src/main.zig +++ b/src/main.zig @@ -161,6 +161,18 @@ fn resolveUserPath( } pub fn main() !u8 { + return runCli() catch |err| switch (err) { + // Downstream pipe closed (e.g., `zfin earnings AAPL | head`). Zig's + // file writer surfaces EPIPE as WriteFailed. Treat as a clean exit + // — the consumer got what it needed and closed the pipe; further + // output isn't an error from our perspective. Matches `ls | head`, + // `git log | head`, etc. + error.WriteFailed, error.BrokenPipe => 0, + else => err, + }; +} + +fn runCli() !u8 { // Long-lived allocator for things that span the whole process. Only // actually used for the early argsAlloc and the TUI path — CLI // commands run under a per-invocation arena (see below).