From edf94ce203894e273ec9cc8dd26978a28ec32466 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 4 Mar 2026 03:58:54 -0800 Subject: [PATCH] don't hardcode to linux --- src/lib.zig | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib.zig b/src/lib.zig index 1159bd28e5dd5dd3083cb8a76b98d70d1206d742..5d353cc1b09a02a4927775fec676b4f13f0f0468 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -1,9 +1,15 @@ const std = @import("std"); +const builtin = @import("builtin"); const string = [:0]const u8; const List = std.ArrayList(string); const extras = @import("extras"); const linux = @import("sys-linux"); +const sys = switch (builtin.target.os.tag) { + .linux => linux, + else => unreachable, // TODO: +}; + var singles: std.ArrayHashMap(string, string, std.array_hash_map.StringContext, true) = undefined; var multis: std.ArrayHashMap(string, List, std.array_hash_map.StringContext, true) = undefined; @@ -68,7 +74,7 @@ pub fn parse(k: FlagDashKind) !std.process.ArgIterator { } } std.log.err("Unrecognized argument: {s}{s}", .{ dash, name }); - linux.exit(1); + sys.exit(1); } return argiter; } @@ -77,7 +83,7 @@ pub fn parseEnv() !void { const alloc = singles.allocator; for (singles.keys(), singles.values()) |k, *v| { - if (linux.getenv(k)) |value| { + if (sys.getenv(k)) |value| { v.* = value; } } @@ -86,7 +92,7 @@ pub fn parseEnv() !void { while (true) : (n += 1) { const w = try std.fmt.allocPrintZ(alloc, "{s}_{d}", .{ k, n }); defer alloc.free(w); - if (linux.getenv(w)) |value| { + if (sys.getenv(w)) |value| { try v.append(value); continue; } -- 2.54.0