summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-05 20:33:42 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-10 10:10:06 -0400
commit3001c74580c1713bd634990a0b2ab351fdec7a98 (patch)
tree6d6bc76d4b057f9c0bc974e2a9302f6b4c65cda1 /src
parent2bc8ca0ca2fefcfb63a37723d7a9bbb9ae76ceb1 (diff)
journalctl: no color for --reboot-- when not on tty
Diffstat (limited to 'src')
-rw-r--r--src/journal/journalctl.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index f404e414f4..af0f4ba3c8 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1333,12 +1333,14 @@ int main(int argc, char *argv[]) {
if (!arg_merge) {
sd_id128_t boot_id;
+ const char *color_on = on_tty() ? ANSI_HIGHLIGHT_ON : "",
+ *color_off = on_tty() ? ANSI_HIGHLIGHT_OFF : "";
r = sd_journal_get_monotonic_usec(j, NULL, &boot_id);
if (r >= 0) {
if (previous_boot_id_valid &&
!sd_id128_equal(boot_id, previous_boot_id))
- printf(ANSI_HIGHLIGHT_ON "-- Reboot --" ANSI_HIGHLIGHT_OFF "\n");
+ printf("%s-- Reboot --%s\n", color_on, color_off);
previous_boot_id = boot_id;
previous_boot_id_valid = true;