mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
Allow $NIX_PAGER to override $PAGER
This commit is contained in:
parent
8b88d25cda
commit
8027083c3a
1 changed files with 5 additions and 4 deletions
|
@ -293,8 +293,9 @@ int handleExceptions(const string & programName, std::function<void()> fun)
|
||||||
RunPager::RunPager()
|
RunPager::RunPager()
|
||||||
{
|
{
|
||||||
if (!isatty(STDOUT_FILENO)) return;
|
if (!isatty(STDOUT_FILENO)) return;
|
||||||
string pager = getEnv("PAGER", "default");
|
char * pager = getenv("NIX_PAGER");
|
||||||
if (pager == "" || pager == "cat") return;
|
if (!pager) pager = getenv("PAGER");
|
||||||
|
if (pager && ((string) pager == "" || (string) pager == "cat")) return;
|
||||||
|
|
||||||
/* Ignore SIGINT. The pager will handle it (and we'll get
|
/* Ignore SIGINT. The pager will handle it (and we'll get
|
||||||
SIGPIPE). */
|
SIGPIPE). */
|
||||||
|
@ -314,8 +315,8 @@ RunPager::RunPager()
|
||||||
throw SysError("dupping stdin");
|
throw SysError("dupping stdin");
|
||||||
if (!getenv("LESS"))
|
if (!getenv("LESS"))
|
||||||
setenv("LESS", "FRSXMK", 1);
|
setenv("LESS", "FRSXMK", 1);
|
||||||
if (pager != "default")
|
if (pager)
|
||||||
execl("/bin/sh", "sh", "-c", pager.c_str(), NULL);
|
execl("/bin/sh", "sh", "-c", pager, NULL);
|
||||||
execlp("pager", "pager", NULL);
|
execlp("pager", "pager", NULL);
|
||||||
execlp("less", "less", NULL);
|
execlp("less", "less", NULL);
|
||||||
execlp("more", "more", NULL);
|
execlp("more", "more", NULL);
|
||||||
|
|
Loading…
Reference in a new issue