Merge pull request #10 from utox39/feat/handle-shell-env-var-not-found
Feat/handle shell env var not found
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
// This is a [Semantic Version](https://semver.org/).
|
// This is a [Semantic Version](https://semver.org/).
|
||||||
// In a future version of Zig it will be used for package deduplication.
|
// In a future version of Zig it will be used for package deduplication.
|
||||||
.version = "0.8.0",
|
.version = "0.8.1",
|
||||||
|
|
||||||
// Together with name, this represents a globally unique package
|
// Together with name, this represents a globally unique package
|
||||||
// identifier. This field is generated by the Zig toolchain when the
|
// identifier. This field is generated by the Zig toolchain when the
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ pub fn getUsername(allocator: std.mem.Allocator) ![]u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn getShell(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);
|
var child = std.process.Child.init(&[_][]const u8{ shell, "--version" }, allocator);
|
||||||
defer allocator.free(shell);
|
defer allocator.free(shell);
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ pub fn getUsername(allocator: std.mem.Allocator) ![]u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn getShell(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);
|
var child = std.process.Child.init(&[_][]const u8{ shell, "--version" }, allocator);
|
||||||
defer allocator.free(shell);
|
defer allocator.free(shell);
|
||||||
|
|||||||
Reference in New Issue
Block a user