handle write failed due to piping through commands like head
This commit is contained in:
parent
f436ca5a86
commit
0d3dfc6a55
1 changed files with 12 additions and 0 deletions
12
src/main.zig
12
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).
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue