util: unify usage of on_tty() in util.c

This commit is contained in:
Lennart Poettering
2012-10-19 00:07:55 +02:00
parent 28917d7dc7
commit 8481248b9f
8 changed files with 19 additions and 62 deletions
-18
View File
@@ -132,26 +132,8 @@ static bool private_bus = false;
static int daemon_reload(DBusConnection *bus, char **args);
static void halt_now(enum action a);
static bool on_tty(void) {
static int t = -1;
/* Note that this is invoked relatively early, before we start
* the pager. That means the value we return reflects whether
* we originally were started on a tty, not if we currently
* are. But this is intended, since we want colour and so on
* when run in our own pager. */
if (_unlikely_(t < 0))
t = isatty(STDOUT_FILENO) > 0;
return t;
}
static void pager_open_if_enabled(void) {
/* Cache result before we open the pager */
on_tty();
if (arg_no_pager)
return;