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 @@...@@ -1,9 +1,15 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
2const string = [:0]const u8;3const string = [:0]const u8;
3const List = std.ArrayList(string);4const List = std.ArrayList(string);
4const extras = @import("extras");5const extras = @import("extras");
5const linux = @import("sys-linux");6const linux = @import("sys-linux");
67
8const sys = switch (builtin.target.os.tag) {
9 .linux => linux,
10 else => unreachable, // TODO:
11};
12
7var singles: std.ArrayHashMap(string, string, std.array_hash_map.StringContext, true) = undefined;13var singles: std.ArrayHashMap(string, string, std.array_hash_map.StringContext, true) = undefined;
8var multis: std.ArrayHashMap(string, List, std.array_hash_map.StringContext, true) = undefined;14var 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 {...@@ -68,7 +74,7 @@ pub fn parse(k: FlagDashKind) !std.process.ArgIterator {
68 }74 }
69 }75 }
70 std.log.err("Unrecognized argument: {s}{s}", .{ dash, name });76 std.log.err("Unrecognized argument: {s}{s}", .{ dash, name });
71 linux.exit(1);77 sys.exit(1);
72 }78 }
73 return argiter;79 return argiter;
74}80}
...@@ -77,7 +83,7 @@ pub fn parseEnv() !void {...@@ -77,7 +83,7 @@ pub fn parseEnv() !void {
77 const alloc = singles.allocator;83 const alloc = singles.allocator;
7884
79 for (singles.keys(), singles.values()) |k, *v| {85 for (singles.keys(), singles.values()) |k, *v| {
80 if (linux.getenv(k)) |value| {86 if (sys.getenv(k)) |value| {
81 v.* = value;87 v.* = value;
82 }88 }
83 }89 }
...@@ -86,7 +92,7 @@ pub fn parseEnv() !void {...@@ -86,7 +92,7 @@ pub fn parseEnv() !void {
86 while (true) : (n += 1) {92 while (true) : (n += 1) {
87 const w = try std.fmt.allocPrintZ(alloc, "{s}_{d}", .{ k, n });93 const w = try std.fmt.allocPrintZ(alloc, "{s}_{d}", .{ k, n });
88 defer alloc.free(w);94 defer alloc.free(w);
89 if (linux.getenv(w)) |value| {95 if (sys.getenv(w)) |value| {
90 try v.append(value);96 try v.append(value);
91 continue;97 continue;
92 }98 }