chiark / gitweb /
util: unify usage of on_tty() in util.c
[elogind.git] / src / systemctl / systemctl.c
index 7d6a6a24f3c29a3ffb55c4f5a6b8e9f009c894c2..d77d534e0bde068ddebdfeb907d616f060bebea0 100644 (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;
 
@@ -2293,9 +2275,10 @@ static void print_status_info(UnitStatusInfo *i) {
         if (i->id && arg_transport != TRANSPORT_SSH) {
                 int flags =
                         arg_all * OUTPUT_SHOW_ALL |
+                        (!on_tty() || pager_have()) * OUTPUT_FULL_WIDTH |
+                        on_tty() * OUTPUT_COLOR |
                         arg_follow * OUTPUT_FOLLOW |
-                        !arg_quiet * OUTPUT_WARN_CUTOFF |
-                        on_tty() * OUTPUT_COLOR;
+                        !arg_quiet * OUTPUT_WARN_CUTOFF;
 
                 printf("\n");
                 show_journal_by_unit(stdout,