From 433b6b4fe205691a290466a73ac6bdbdf5b43cf9 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Tue, 19 Nov 2024 10:31:13 -0500 Subject: [PATCH] os: replace PATH_SEP with std.fs.path.delimiter This standard library symbol is equivalent. --- src/os/env.zig | 10 ++-------- src/os/main.zig | 1 - src/termio/Exec.zig | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/os/env.zig b/src/os/env.zig index b40d2fef1..8d6331f8d 100644 --- a/src/os/env.zig +++ b/src/os/env.zig @@ -3,12 +3,6 @@ const builtin = @import("builtin"); const Allocator = std.mem.Allocator; const posix = std.posix; -/// The separator used in environment variables such as PATH. -pub const PATH_SEP = switch (builtin.os.tag) { - .windows => ";", - else => ":", -}; - /// Append a value to an environment variable such as PATH. /// The returned value is always allocated so it must be freed. pub fn appendEnv( @@ -33,9 +27,9 @@ pub fn appendEnvAlways( current: []const u8, value: []const u8, ) ![]u8 { - return try std.fmt.allocPrint(alloc, "{s}{s}{s}", .{ + return try std.fmt.allocPrint(alloc, "{s}{c}{s}", .{ current, - PATH_SEP, + std.fs.path.delimiter, value, }); } diff --git a/src/os/main.zig b/src/os/main.zig index 48a712d40..22765f546 100644 --- a/src/os/main.zig +++ b/src/os/main.zig @@ -25,7 +25,6 @@ pub const windows = @import("windows.zig"); // Functions and types pub const CFReleaseThread = @import("cf_release_thread.zig"); pub const TempDir = @import("TempDir.zig"); -pub const PATH_SEP = env.PATH_SEP; pub const appendEnv = env.appendEnv; pub const appendEnvAlways = env.appendEnvAlways; pub const getenv = env.getenv; diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 3bf288cb7..07aa43c42 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -780,7 +780,7 @@ const Subprocess = struct { // then we just set it to the directory of the binary. if (env.get("PATH")) |path| { // Verify that our path doesn't already contain this entry - var it = std.mem.tokenizeScalar(u8, path, internal_os.PATH_SEP[0]); + var it = std.mem.tokenizeScalar(u8, path, std.fs.path.delimiter); while (it.next()) |entry| { if (std.mem.eql(u8, entry, exe_dir)) break :ghostty_path; }