From c13601fca827bc236ab0c818f296b78a00608d82 Mon Sep 17 00:00:00 2001 From: utox39 Date: Wed, 26 Feb 2025 16:50:43 +0100 Subject: [PATCH] feat(macos): add shell info --- src/macos/macos.zig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/macos/macos.zig b/src/macos/macos.zig index 6e97017..8a43efd 100644 --- a/src/macos/macos.zig +++ b/src/macos/macos.zig @@ -65,3 +65,21 @@ pub fn getSystemUptime() !SystemUptime { .minutes = @as(i8, @intFromFloat(minutes)), }; } + +pub fn getShell(allocator: std.mem.Allocator) ![]u8 { + const shell = try std.process.getEnvVarOwned(allocator, "SHELL"); + + var child = std.process.Child.init(&[_][]const u8{ shell, "--version" }, allocator); + // defer child.deinit(); + + child.stdout_behavior = .Pipe; + child.stderr_behavior = .Pipe; + + try child.spawn(); + + const output = try child.stdout.?.reader().readAllAlloc(allocator, 1024 * 1024); + + _ = try child.wait(); + + return output; +}