mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-19 10:16:12 +03:00
core: fix puralization of src/os/env.zig Errors->Error
This commit is contained in:
@ -3,7 +3,7 @@ const builtin = @import("builtin");
|
|||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const posix = std.posix;
|
const posix = std.posix;
|
||||||
|
|
||||||
pub const Errors = Allocator.Error;
|
pub const Error = Allocator.Error;
|
||||||
|
|
||||||
/// Append a value to an environment variable such as PATH.
|
/// Append a value to an environment variable such as PATH.
|
||||||
/// The returned value is always allocated so it must be freed.
|
/// The returned value is always allocated so it must be freed.
|
||||||
@ -11,7 +11,7 @@ pub fn appendEnv(
|
|||||||
alloc: Allocator,
|
alloc: Allocator,
|
||||||
current: []const u8,
|
current: []const u8,
|
||||||
value: []const u8,
|
value: []const u8,
|
||||||
) Errors![]u8 {
|
) Error![]u8 {
|
||||||
// If there is no prior value, we return it as-is
|
// If there is no prior value, we return it as-is
|
||||||
if (current.len == 0) return try alloc.dupe(u8, value);
|
if (current.len == 0) return try alloc.dupe(u8, value);
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ pub fn appendEnvAlways(
|
|||||||
alloc: Allocator,
|
alloc: Allocator,
|
||||||
current: []const u8,
|
current: []const u8,
|
||||||
value: []const u8,
|
value: []const u8,
|
||||||
) Errors![]u8 {
|
) Error![]u8 {
|
||||||
return try std.fmt.allocPrint(alloc, "{s}{c}{s}", .{
|
return try std.fmt.allocPrint(alloc, "{s}{c}{s}", .{
|
||||||
current,
|
current,
|
||||||
std.fs.path.delimiter,
|
std.fs.path.delimiter,
|
||||||
@ -42,7 +42,7 @@ pub fn prependEnv(
|
|||||||
alloc: Allocator,
|
alloc: Allocator,
|
||||||
current: []const u8,
|
current: []const u8,
|
||||||
value: []const u8,
|
value: []const u8,
|
||||||
) Errors![]u8 {
|
) Error![]u8 {
|
||||||
// If there is no prior value, we return it as-is
|
// If there is no prior value, we return it as-is
|
||||||
if (current.len == 0) return try alloc.dupe(u8, value);
|
if (current.len == 0) return try alloc.dupe(u8, value);
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ pub const GetEnvResult = struct {
|
|||||||
/// This will allocate on Windows but not on other platforms. The returned
|
/// This will allocate on Windows but not on other platforms. The returned
|
||||||
/// value should have deinit called to do the proper cleanup no matter what
|
/// value should have deinit called to do the proper cleanup no matter what
|
||||||
/// platform you are on.
|
/// platform you are on.
|
||||||
pub fn getenv(alloc: Allocator, key: []const u8) Errors!?GetEnvResult {
|
pub fn getenv(alloc: Allocator, key: []const u8) Error!?GetEnvResult {
|
||||||
return switch (builtin.os.tag) {
|
return switch (builtin.os.tag) {
|
||||||
// Non-Windows doesn't need to allocate
|
// Non-Windows doesn't need to allocate
|
||||||
else => if (posix.getenv(key)) |v| .{ .value = v } else null,
|
else => if (posix.getenv(key)) |v| .{ .value = v } else null,
|
||||||
|
Reference in New Issue
Block a user