X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fjournalctl.c;h=f4b651855771a42b7708cb1607ba43668f7b273d;hb=8481248b9fbddc6d5e6ff26eb23505ef13dc85f7;hp=5185b4b398286f2589e90059b3b967ca14d37437;hpb=cd4b13e0bfe9281a0d2c0c3bef1c589d0684950b;p=elogind.git diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 5185b4b39..f4b651855 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, @@ -840,7 +825,6 @@ int main(int argc, char *argv[]) { bool need_seek = false; sd_id128_t previous_boot_id; bool previous_boot_id_valid = false; - bool have_pager; unsigned n_shown = 0; log_parse_environment(); @@ -983,8 +967,8 @@ int main(int argc, char *argv[]) { goto finish; } - on_tty(); - have_pager = !arg_no_pager && !arg_follow && pager_open(); + if (!arg_no_pager && !arg_follow) + pager_open(); if (!arg_quiet) { usec_t start, end; @@ -1048,7 +1032,7 @@ int main(int argc, char *argv[]) { flags = arg_all * OUTPUT_SHOW_ALL | - (!on_tty() || have_pager) * OUTPUT_FULL_WIDTH | + (!on_tty() || pager_have()) * OUTPUT_FULL_WIDTH | on_tty() * OUTPUT_COLOR; r = output_journal(stdout, j, arg_output, 0, flags);