diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-10-18 23:59:41 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-10-19 00:07:55 +0200 |
commit | 8481248b9fbddc6d5e6ff26eb23505ef13dc85f7 (patch) | |
tree | e4fe79bad17efaf2c8e6382180be720776e9d73c /src/journal | |
parent | 28917d7dc711746795f7e6468c06c1983a5cdf53 (diff) |
util: unify usage of on_tty() in util.c
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/journal-verify.c | 4 | ||||
-rw-r--r-- | src/journal/journalctl.c | 21 |
2 files changed, 4 insertions, 21 deletions
diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c index 551f04af35..1a67d5a04b 100644 --- a/src/journal/journal-verify.c +++ b/src/journal/journal-verify.c @@ -178,7 +178,7 @@ static void draw_progress(uint64_t p, usec_t *last_usec) { unsigned n, i, j, k; usec_t z, x; - if (!isatty(STDOUT_FILENO)) + if (!on_tty()) return; z = now(CLOCK_MONOTONIC); @@ -212,7 +212,7 @@ static void draw_progress(uint64_t p, usec_t *last_usec) { static void flush_progress(void) { unsigned n, i; - if (!isatty(STDOUT_FILENO)) + if (!on_tty()) return; n = (3 * columns()) / 4; diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index d6f19e900a..f4b6518557 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -400,21 +400,6 @@ static int parse_argv(int argc, char *argv[]) { return 1; } -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 int generate_new_id128(void) { sd_id128_t id; int r; @@ -697,7 +682,7 @@ static int setup_keys(void) { goto finish; } - if (isatty(STDOUT_FILENO)) { + if (on_tty()) { fprintf(stderr, "\n" "The new key pair has been generated. The " ANSI_HIGHLIGHT_ON "secret sealing key" ANSI_HIGHLIGHT_OFF " has been written to\n" @@ -719,7 +704,7 @@ static int setup_keys(void) { printf("/%llx-%llx\n", (unsigned long long) n, (unsigned long long) arg_interval); - if (isatty(STDOUT_FILENO)) { + if (on_tty()) { char tsb[FORMAT_TIMESPAN_MAX], *hn; fprintf(stderr, @@ -982,8 +967,6 @@ int main(int argc, char *argv[]) { goto finish; } - on_tty(); - if (!arg_no_pager && !arg_follow) pager_open(); |