about summary refs log tree commit diff
path: root/src/libmain/shared.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-01-02T14·26+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-01-02T14·26+0100
commit8027083c3afaa5a05052518fe96b38f8dbafd6e2 (patch)
treed8ce3f3661817cbfa5ef69b1f18bd4a15c79cf8c /src/libmain/shared.cc
parent8b88d25cda1467018bdbe1659e6b994a2e66f4fb (diff)
Allow $NIX_PAGER to override $PAGER
Diffstat (limited to 'src/libmain/shared.cc')
-rw-r--r--src/libmain/shared.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 082705d9ed5e..c83e997b2307 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -293,8 +293,9 @@ int handleExceptions(const string & programName, std::function<void()> fun)
 RunPager::RunPager()
 {
     if (!isatty(STDOUT_FILENO)) return;
-    string pager = getEnv("PAGER", "default");
-    if (pager == "" || pager == "cat") return;
+    char * pager = getenv("NIX_PAGER");
+    if (!pager) pager = getenv("PAGER");
+    if (pager && ((string) pager == "" || (string) pager == "cat")) return;
 
     /* Ignore SIGINT. The pager will handle it (and we'll get
        SIGPIPE). */
@@ -314,8 +315,8 @@ RunPager::RunPager()
             throw SysError("dupping stdin");
         if (!getenv("LESS"))
             setenv("LESS", "FRSXMK", 1);
-        if (pager != "default")
-            execl("/bin/sh", "sh", "-c", pager.c_str(), NULL);
+        if (pager)
+            execl("/bin/sh", "sh", "-c", pager, NULL);
         execlp("pager", "pager", NULL);
         execlp("less", "less", NULL);
         execlp("more", "more", NULL);