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
This commit is contained in:
parent
eca53bfab0
commit
4202eee084
17
launcher.c
17
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user