Various changes.

This commit is contained in:
Greyson Parrelli committed 2026-10-28 09:22:29 -04:00
1 parent bb90255002
commit 3475ca95c0
29 files changed
+110 -85

No files matched your search

+6 -6
View File
@@ -126,7 +126,7 @@ pub fn create(
const envp_z = try buildEnv(alloc, env_extra);
defer freeEnv(alloc, envp_z);
const slave_path_z = try alloc.dupeZ(u8, slave_path);
const slave_path_z = try alloc.dupeSentinel(u8, slave_path, 0);
defer alloc.free(slave_path_z);
const pid = c.fork();
@@ -226,12 +226,12 @@ fn buildEnv(
if (std.mem.startsWith(u8, span, "TERM=")) continue;
if (std.mem.startsWith(u8, span, "COLORTERM=")) continue;
if (shadowedBy(span, extra)) continue;
try list.append(alloc, (try alloc.dupeZ(u8, span)).ptr);
try list.append(alloc, (try alloc.dupeSentinel(u8, span, 0)).ptr);
}
try list.append(alloc, (try alloc.dupeZ(u8, "TERM=xterm-256color")).ptr);
try list.append(alloc, (try alloc.dupeZ(u8, "COLORTERM=truecolor")).ptr);
try list.append(alloc, (try alloc.dupeSentinel(u8, "TERM=xterm-256color", 0)).ptr);
try list.append(alloc, (try alloc.dupeSentinel(u8, "COLORTERM=truecolor", 0)).ptr);
for (extra) |entry| {
try list.append(alloc, (try alloc.dupeZ(u8, entry)).ptr);
try list.append(alloc, (try alloc.dupeSentinel(u8, entry, 0)).ptr);
}
const result = try alloc.allocSentinel(?[*:0]const u8, list.items.len, null);
@@ -264,7 +264,7 @@ fn freeEnv(alloc: std.mem.Allocator, envp: [:null]?[*:0]const u8) void {
/// portable API for it, and this app is Linux-only regardless.
pub fn cwd(self: Pty, buf: []u8) ?[]const u8 {
var link_buf: [64]u8 = undefined;
const link = std.fmt.bufPrintZ(&link_buf, "/proc/{d}/cwd", .{self.pid}) catch return null;
const link = std.mem.printSentinel(&link_buf, "/proc/{d}/cwd", .{self.pid}, 0) catch return null;
const n = c.readlink(link.ptr, buf.ptr, buf.len);
if (n <= 0) return null;