mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
termio/exec: check cwd validity
This commit is contained in:
@ -614,12 +614,24 @@ const Subprocess = struct {
|
|||||||
return pty.master;
|
return pty.master;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we can't access the cwd, then don't set any cwd and inherit.
|
||||||
|
// This is important because our cwd can be set by the shell (OSC 7)
|
||||||
|
// and we don't want to break new windows.
|
||||||
|
const cwd: ?[]const u8 = if (self.cwd) |proposed| cwd: {
|
||||||
|
if (std.fs.accessAbsolute(proposed, .{})) {
|
||||||
|
break :cwd proposed;
|
||||||
|
} else |err| {
|
||||||
|
log.warn("cannot access cwd, ignoring: {}", .{err});
|
||||||
|
break :cwd null;
|
||||||
|
}
|
||||||
|
} else null;
|
||||||
|
|
||||||
// Build our subcommand
|
// Build our subcommand
|
||||||
var cmd: Command = .{
|
var cmd: Command = .{
|
||||||
.path = self.path,
|
.path = self.path,
|
||||||
.args = self.args,
|
.args = self.args,
|
||||||
.env = &self.env,
|
.env = &self.env,
|
||||||
.cwd = self.cwd,
|
.cwd = cwd,
|
||||||
.stdin = .{ .handle = pty.slave },
|
.stdin = .{ .handle = pty.slave },
|
||||||
.stdout = .{ .handle = pty.slave },
|
.stdout = .{ .handle = pty.slave },
|
||||||
.stderr = .{ .handle = pty.slave },
|
.stderr = .{ .handle = pty.slave },
|
||||||
|
Reference in New Issue
Block a user