this is mostly a test and example for the libexec helper infrastructure, but it also lets us simplify pager launching until we we can more easily handle executable-not-found errors the launch fallbacks would cause when using runProgram2 instead of fork. ideally we'd use `posix_spawn` later. fixes #1104 Change-Id: Ia33cc12e8a9d60ffad6f5c055bb1b8b596810e64
20 lines
497 B
C++
20 lines
497 B
C++
#include "common.hh"
|
|
|
|
LIBEXEC_HELPER(0)
|
|
|
|
int helperMain(const char * name, std::span<char *> args) noexcept
|
|
{
|
|
auto pager = args.empty() ? nullptr : args[0];
|
|
|
|
if (!getenv("LESS")) {
|
|
setenv("LESS", "FRSXMK", 1);
|
|
}
|
|
if (pager) {
|
|
execl("/bin/sh", "sh", "-c", pager, nullptr);
|
|
}
|
|
execlp("pager", "pager", nullptr);
|
|
execlp("less", "less", nullptr);
|
|
execlp("more", "more", nullptr);
|
|
die("could not find a pager to run, please set PAGER or NIX_PAGER");
|
|
}
|