From 2b2ffb7787df634aee1681dac7be48e986d34337 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 29 Oct 2009 00:23:57 -0400 Subject: If isatty is available, no colors/pager for non-ttys --- src/report.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/report.h') 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::on_with(whence, text); }); +#else // HAVE_ISATTY + OPTION__ + (report_t, pager_, + CTOR(report_t, pager_) { + } + virtual void on_with(const optional& whence, const value_t& text) { + string cmd(text.to_string()); + if (cmd == "" || cmd == "false" || cmd == "off" || + cmd == "none" || cmd == "no" || cmd == "disable") + option_t::off(); + else + option_t::on_with(whence, text); + }); +#endif // HAVE_ISATTY OPTION(report_t, payee_as_account); -- cgit v1.2.3