diff options
author | Martin Michlmayr <tbm@cyrius.com> | 2020-06-16 13:17:53 +0800 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2020-06-18 11:00:48 -0700 |
commit | 21280a9da3ca6ed70a10f95e1ef0717d5f65ee99 (patch) | |
tree | ef0dbe7fb1b8764381a8ae22c250545115cb4d8e | |
parent | bbd10b24bed3a82aef693dfe35c246714733b30b (diff) | |
download | fork-ledger-21280a9da3ca6ed70a10f95e1ef0717d5f65ee99.tar.gz fork-ledger-21280a9da3ca6ed70a10f95e1ef0717d5f65ee99.tar.bz2 fork-ledger-21280a9da3ca6ed70a10f95e1ef0717d5f65ee99.zip |
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
-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 } } }); |