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 /src | |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/report.h | 25 |
1 files changed, 15 insertions, 10 deletions
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 } } }); |