authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-03-04 03:58:54 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-03-04 03:58:54 -08:00
logedf94ce203894e273ec9cc8dd26978a28ec32466
tree734dd6fac97435fe0f50b463a9fba4d948dd3193
parentee9e63bc66096854cbc431fd4f0f190454fe93bd
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

don't hardcode to linux


1 files changed, 9 insertions(+), 3 deletions(-)

src/lib.zig+9-3
......@@ -1,9 +1,15 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const string = [:0]const u8;
34const List = std.ArrayList(string);
45const extras = @import("extras");
56const linux = @import("sys-linux");
67
8const sys = switch (builtin.target.os.tag) {
9 .linux => linux,
10 else => unreachable, // TODO:
11};
12
713var singles: std.ArrayHashMap(string, string, std.array_hash_map.StringContext, true) = undefined;
814var multis: std.ArrayHashMap(string, List, std.array_hash_map.StringContext, true) = undefined;
915
......@@ -68,7 +74,7 @@ pub fn parse(k: FlagDashKind) !std.process.ArgIterator {
6874 }
6975 }
7076 std.log.err("Unrecognized argument: {s}{s}", .{ dash, name });
71 linux.exit(1);
77 sys.exit(1);
7278 }
7379 return argiter;
7480}
......@@ -77,7 +83,7 @@ pub fn parseEnv() !void {
7783 const alloc = singles.allocator;
7884
7985 for (singles.keys(), singles.values()) |k, *v| {
80 if (linux.getenv(k)) |value| {
86 if (sys.getenv(k)) |value| {
8187 v.* = value;
8288 }
8389 }
......@@ -86,7 +92,7 @@ pub fn parseEnv() !void {
8692 while (true) : (n += 1) {
8793 const w = try std.fmt.allocPrintZ(alloc, "{s}_{d}", .{ k, n });
8894 defer alloc.free(w);
89 if (linux.getenv(w)) |value| {
95 if (sys.getenv(w)) |value| {
9096 try v.append(value);
9197 continue;
9298 }