Merge pull request #2733 from jparise/path_sep

os: replace PATH_SEP with std.fs.path.delimiter
This commit is contained in:
Mitchell Hashimoto
2024-11-19 10:12:27 -08:00
committed by GitHub
3 changed files with 3 additions and 10 deletions

View File

@ -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,
});
}

View File

@ -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;

View File

@ -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;
}