674ca7
From 701ba7165d9b8265cb94a1aea6ab478271d6265f Mon Sep 17 00:00:00 2001
674ca7
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
674ca7
Date: Wed, 5 Jun 2013 20:33:42 -0400
674ca7
Subject: [PATCH] journalctl: no color for --reboot-- when not on tty
674ca7
674ca7
(cherry picked from commit 3001c74580c1713bd634990a0b2ab351fdec7a98)
674ca7
---
674ca7
 src/journal/journalctl.c | 4 +++-
674ca7
 1 file changed, 3 insertions(+), 1 deletion(-)
674ca7
674ca7
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
674ca7
index 3e6817a581..c21182f2ac 100644
674ca7
--- a/src/journal/journalctl.c
674ca7
+++ b/src/journal/journalctl.c
674ca7
@@ -1333,12 +1333,14 @@ int main(int argc, char *argv[]) {
674ca7
 
674ca7
                         if (!arg_merge) {
674ca7
                                 sd_id128_t boot_id;
674ca7
+                                const char *color_on = on_tty() ? ANSI_HIGHLIGHT_ON : "",
674ca7
+                                           *color_off = on_tty() ? ANSI_HIGHLIGHT_OFF : "";
674ca7
 
674ca7
                                 r = sd_journal_get_monotonic_usec(j, NULL, &boot_id);
674ca7
                                 if (r >= 0) {
674ca7
                                         if (previous_boot_id_valid &&
674ca7
                                             !sd_id128_equal(boot_id, previous_boot_id))
674ca7
-                                                printf(ANSI_HIGHLIGHT_ON "-- Reboot --" ANSI_HIGHLIGHT_OFF "\n");
674ca7
+                                                printf("%s-- Reboot --%s\n", color_on, color_off);
674ca7
 
674ca7
                                         previous_boot_id = boot_id;
674ca7
                                         previous_boot_id_valid = true;