mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
termio/exec: fall back to default command if specified command not found
Fixes #880 If a command is specified but it can't be found, then we try to fallback to a default command like "sh" and log the issue. This prevents Ghostty from simply exiting.
This commit is contained in:
@ -722,13 +722,28 @@ const Subprocess = struct {
|
|||||||
const alloc = arena.allocator();
|
const alloc = arena.allocator();
|
||||||
|
|
||||||
// Determine the path to the binary we're executing
|
// Determine the path to the binary we're executing
|
||||||
|
const default_path = switch (builtin.os.tag) {
|
||||||
|
.windows => "cmd.exe",
|
||||||
|
else => "sh",
|
||||||
|
};
|
||||||
const path = try Command.expandPath(
|
const path = try Command.expandPath(
|
||||||
alloc,
|
alloc,
|
||||||
opts.full_config.command orelse switch (builtin.os.tag) {
|
opts.full_config.command orelse default_path,
|
||||||
.windows => "cmd.exe",
|
) orelse path: {
|
||||||
else => "sh",
|
// If we had a command specified, try to at least fall
|
||||||
},
|
// back to a default value like "sh" so that Ghostty
|
||||||
) orelse return error.CommandNotFound;
|
// launches.
|
||||||
|
if (opts.full_config.command) |command| {
|
||||||
|
log.warn("unable to find command, fallbacking back to default command={s}", .{command});
|
||||||
|
if (try Command.expandPath(
|
||||||
|
alloc,
|
||||||
|
default_path,
|
||||||
|
)) |path| break :path path;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.warn("unable to find default command to launch, exiting", .{});
|
||||||
|
return error.CommandNotFound;
|
||||||
|
};
|
||||||
|
|
||||||
// On macOS, we launch the program as a login shell. This is a Mac-specific
|
// On macOS, we launch the program as a login shell. This is a Mac-specific
|
||||||
// behavior (see other terminals). Terminals in general should NOT be
|
// behavior (see other terminals). Terminals in general should NOT be
|
||||||
|
Reference in New Issue
Block a user