From 21280a9da3ca6ed70a10f95e1ef0717d5f65ee99 Mon Sep 17 00:00:00 2001 From: Martin Michlmayr Date: Tue, 16 Jun 2020 13:17:53 +0800 Subject: Use PAGER when environment variable is set The code looked for "less" if $PAGER is not set, but it didn't actually use $PAGER when it it defined. Fixes #1674 --- src/report.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/report.h b/src/report.h index 8de38547..95d87e1e 100644 --- a/src/report.h +++ b/src/report.h @@ -811,16 +811,21 @@ public: OPTION__ (report_t, pager_, CTOR(report_t, pager_) { - if (! std::getenv("PAGER") && isatty(STDOUT_FILENO)) { - bool have_less = false; - if (exists(path("/opt/local/bin/less")) || - exists(path("/usr/local/bin/less")) || - exists(path("/usr/bin/less"))) - have_less = true; - - if (have_less) { - on(none, "less"); - setenv("LESS", "-FRSX", 0); // don't overwrite + if (isatty(STDOUT_FILENO)) { + if (! std::getenv("PAGER")) { + bool have_less = false; + if (exists(path("/opt/local/bin/less")) || + exists(path("/usr/local/bin/less")) || + exists(path("/usr/bin/less"))) + have_less = true; + + if (have_less) { + on(none, "less"); + setenv("LESS", "-FRSX", 0); // don't overwrite + } + } else { + on(none, std::getenv("PAGER")); + setenv("LESS", "-FRSX", 0); // don't overwrite } } }); -- cgit v1.2.3