From: Zbigniew Jędrzejewski-Szmek Date: Thu, 11 Apr 2013 22:11:47 +0000 (-0400) Subject: systemctl: show the name of failing unit in red X-Git-Tag: v202~141 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=0ad4e1a872e789c77828d4c4825a56241103650c systemctl: show the name of failing unit in red It makes it easier to pick out problematic unit names from a long list. --- diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 0e6087c62..a95060550 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -353,8 +353,8 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) { for (u = unit_infos; u < unit_infos + c; u++) { char _cleanup_free_ *e = NULL; - const char *on_loaded, *off_loaded; - const char *on_active, *off_active; + const char *on_loaded, *off_loaded, *on = ""; + const char *on_active, *off_active, *off = ""; if (!output_show_unit(u)) continue; @@ -373,21 +373,21 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) { n_shown++; if (streq(u->load_state, "error")) { - on_loaded = ansi_highlight_red(true); - off_loaded = ansi_highlight_red(false); + on_loaded = on = ansi_highlight_red(true); + off_loaded = off = ansi_highlight_red(false); } else on_loaded = off_loaded = ""; if (streq(u->active_state, "failed")) { - on_active = ansi_highlight_red(true); - off_active = ansi_highlight_red(false); + on_active = on = ansi_highlight_red(true); + off_active = off = ansi_highlight_red(false); } else on_active = off_active = ""; e = arg_full ? NULL : ellipsize(u->id, id_len, 33); - printf("%-*s %s%-6s%s %s%-*s %-*s%s %-*s", - id_len, e ? e : u->id, + printf("%s%-*s%s %s%-6s%s %s%-*s %-*s%s %-*s", + on, id_len, e ? e : u->id, off, on_loaded, u->load_state, off_loaded, on_active, active_len, u->active_state, sub_len, u->sub_state, off_active,