diff options
-rw-r--r-- | doc/NEWS.md | 4 | ||||
-rw-r--r-- | src/report.h | 25 |
2 files changed, 19 insertions, 10 deletions
diff --git a/doc/NEWS.md b/doc/NEWS.md index 326063d3..c310b087 100644 --- a/doc/NEWS.md +++ b/doc/NEWS.md @@ -1,5 +1,9 @@ # Ledger NEWS +## 3.2.x (unreleased) + +- Use $PAGER when environment variable is set (bug #1674) + ## 3.2.1 (2020-05-18) - Fix regression with expression evaluation by reverting commit 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 } } }); |