From 3ee842e1b710b0f6ac15b8702ed189e9fc77111b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 30 Dec 2023 15:36:13 -0800 Subject: [PATCH] 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. --- src/config/Config.zig | 47 ------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/src/config/Config.zig b/src/config/Config.zig index 772458b57..ccdd51429 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -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 // does the same. In the future we should change to a tagged union. if (std.mem.eql(u8, wd, "inherit")) self.@"working-directory" = null;