config: remove command validation

Abnormal exit detection is more robust, and this validation always had
issues for example we didn't parse shell escapes and so on.
This commit is contained in:
Mitchell Hashimoto
2023-12-30 15:36:13 -08:00
parent 3fae05e2dc
commit 3ee842e1b7

View File

@ -1707,53 +1707,6 @@ pub fn finalize(self: *Config) !void {
} }
} }
if (self.command) |command| command: {
// If the command has a space in it, we skip the check below because
// its probably a multi-argument command. These types of commands
// can contain full shell escapes and other characters and we don't
// want to reimplement that all here. The point of the check below
// is MOSTLY to find people who do `command = myshell` where "myshell"
// is installed by something like Homebrew and therefore isn't available
// to a login shell. We will do more robust checks in the future by
// simply checking if the command exited with an error.
if (std.mem.indexOf(u8, command, " ") != null) break :command;
// If the path is not absolute then we want to expand it. We use our
// current path because our current path is what will be available
// to our termio launcher.
if (!std.fs.path.isAbsolute(command)) {
const expanded = Command.expandPath(alloc, command) catch |err| expanded: {
log.warn("failed to expand command path={s} err={}", .{ command, err });
break :expanded null;
};
if (expanded) |v| {
self.command = v;
} else {
// If the command is not found on the path, we put an error
// but we still allow the command to remain unchanged and try
// to launch it later.
try self._errors.add(alloc, .{
.message = try std.fmt.allocPrintZ(
alloc,
"command {s}: not found on PATH, use an absolute path",
.{command},
),
});
}
} else {
std.fs.accessAbsolute(command, .{}) catch {
try self._errors.add(alloc, .{
.message = try std.fmt.allocPrintZ(
alloc,
"command {s}: file not found",
.{command},
),
});
};
}
}
// If we have the special value "inherit" then set it to null which // If we have the special value "inherit" then set it to null which
// does the same. In the future we should change to a tagged union. // does the same. In the future we should change to a tagged union.
if (std.mem.eql(u8, wd, "inherit")) self.@"working-directory" = null; if (std.mem.eql(u8, wd, "inherit")) self.@"working-directory" = null;