feat(shell): handle 'SHELL' env var not found

This commit is contained in:
utox39
2025-08-04 00:35:09 +02:00
parent 6574945e56
commit 5b423d1cef
2 changed files with 6 additions and 2 deletions

View File

@@ -9,7 +9,9 @@ pub fn getUsername(allocator: std.mem.Allocator) ![]u8 {
}
pub fn getShell(allocator: std.mem.Allocator) ![]u8 {
const shell = try std.process.getEnvVarOwned(allocator, "SHELL");
const shell = std.process.getEnvVarOwned(allocator, "SHELL") catch |err| if (err == error.EnvironmentVariableNotFound) {
return allocator.dupe(u8, "Unknown");
} else return err;
var child = std.process.Child.init(&[_][]const u8{ shell, "--version" }, allocator);
defer allocator.free(shell);