From 4202eee084ed897964e281389bc81a7a1d131596 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 22 Aug 2020 09:12:50 +0530 Subject: [PATCH] Fix launcher on OpenBSD OpenBSD has apparently refused to move into the 21st century and lacks a way of determining path to the executable. So we use a kludge, looking for kitty in PATH and using that. To make it work, simply put a symlink to kitty somewhere in PATH. Fixes #2675 --- launcher.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/launcher.c b/launcher.c index f0e9d07a4..664a87f94 100644 --- a/launcher.c +++ b/launcher.c @@ -148,6 +148,23 @@ read_exe_path(char *exe, size_t buf_sz) { return true; } +#elif defined(__OpenBSD__) +static inline bool +read_exe_path(char *exe, size_t buf_sz) { + const char *path = getenv("PATH"); + if (!path) { fprintf(stderr, "No PATH environment variable set, aborting\n"); return false; } + char buf[PATH_MAX + 1] = {0}; + strncpy(buf, path, PATH_MAX); + char *token = strtok(buf, ":"); + while (token != NULL) { + char q[PATH_MAX + 1] = {0}; + snprintf(q, PATH_MAX, "%s/kitty", token); + if (safe_realpath(q, exe, buf_sz)) return true; + } + fprintf(stderr, "kitty not found in PATH aborting\n"); + return false; +} + #else static inline bool