summaryrefslogtreecommitdiff
path: root/src/report.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-29 00:23:57 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-29 00:23:57 -0400
commit2b2ffb7787df634aee1681dac7be48e986d34337 (patch)
tree8e93df310b06f56892341f76d024de4ebe7d3881 /src/report.h
parent52433e56e562976887325ce48a6271abb82a89aa (diff)
downloadfork-ledger-2b2ffb7787df634aee1681dac7be48e986d34337.tar.gz
fork-ledger-2b2ffb7787df634aee1681dac7be48e986d34337.tar.bz2
fork-ledger-2b2ffb7787df634aee1681dac7be48e986d34337.zip
If isatty is available, no colors/pager for non-ttys
Diffstat (limited to 'src/report.h')
-rw-r--r--src/report.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/report.h b/src/report.h
index 294af19a..22008af6 100644
--- a/src/report.h
+++ b/src/report.h
@@ -630,10 +630,11 @@ public:
OPTION(report_t, output_); // -o
+#ifdef HAVE_ISATTY
OPTION__
(report_t, pager_,
CTOR(report_t, pager_) {
- if (! std::getenv("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")) ||
@@ -654,6 +655,20 @@ public:
else
option_t<report_t>::on_with(whence, text);
});
+#else // HAVE_ISATTY
+ OPTION__
+ (report_t, pager_,
+ CTOR(report_t, pager_) {
+ }
+ virtual void on_with(const optional<string>& whence, const value_t& text) {
+ string cmd(text.to_string());
+ if (cmd == "" || cmd == "false" || cmd == "off" ||
+ cmd == "none" || cmd == "no" || cmd == "disable")
+ option_t<report_t>::off();
+ else
+ option_t<report_t>::on_with(whence, text);
+ });
+#endif // HAVE_ISATTY
OPTION(report_t, payee_as_account);