From 9481f7769390b934fba92441be32b39287cc93d7 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 20 Aug 2014 21:22:41 +0200 Subject: [PATCH] Provide reasonable default flags for $LESS Borrowed from systemd. --- src/libmain/shared.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 263e1744c..5a740367c 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -305,13 +305,14 @@ RunPager::RunPager() pid = startProcess([&]() { if (dup2(toPager.readSide, STDIN_FILENO) == -1) throw SysError("dupping stdin"); + if (!getenv("LESS")) + setenv("LESS", "FRSXMK", 1); execl("/bin/sh", "sh", "-c", pager.c_str(), NULL); throw SysError(format("executing ‘%1%’") % pager); }); if (dup2(toPager.writeSide, STDOUT_FILENO) == -1) throw SysError("dupping stdout"); - }