goto finish;
}
- loop_write(ttyfd, "\x1B[1m", 4, false);
+ loop_write(ttyfd, ANSI_HIGHLIGHT_ON, sizeof(ANSI_HIGHLIGHT_ON)-1, false);
loop_write(ttyfd, message, strlen(message), false);
loop_write(ttyfd, " ", 1, false);
- loop_write(ttyfd, "\x1B[0m", 4, false);
+ loop_write(ttyfd, ANSI_HIGHLIGHT_OFF, sizeof(ANSI_HIGHLIGHT_OFF)-1, false);
new_termios = old_termios;
new_termios.c_lflag &= ~(ICANON|ECHO);
break;
case JOB_FAILED:
- unit_status_printf(u, ANSI_HIGHLIGHT_ON "FAILED" ANSI_HIGHLIGHT_OFF, "Failed to start %s", unit_description(u));
+ unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON "FAILED" ANSI_HIGHLIGHT_OFF, "Failed to start %s", unit_description(u));
unit_status_printf(u, NULL, "See 'systemctl status %s' for details.", u->meta.id);
break;
case JOB_DEPENDENCY:
- unit_status_printf(u, ANSI_HIGHLIGHT_ON " ABORT" ANSI_HIGHLIGHT_OFF, "Dependency failed. Aborted start of %s", unit_description(u));
+ unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON " ABORT" ANSI_HIGHLIGHT_OFF, "Dependency failed. Aborted start of %s", unit_description(u));
break;
case JOB_TIMEOUT:
- unit_status_printf(u, ANSI_HIGHLIGHT_ON " TIME " ANSI_HIGHLIGHT_OFF, "Timed out starting %s", unit_description(u));
+ unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON " TIME " ANSI_HIGHLIGHT_OFF, "Timed out starting %s", unit_description(u));
break;
default:
switch (result) {
case JOB_TIMEOUT:
- unit_status_printf(u, ANSI_HIGHLIGHT_ON " TIME " ANSI_HIGHLIGHT_OFF, "Timed out stopping %s", unit_description(u));
+ unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON " TIME " ANSI_HIGHLIGHT_OFF, "Timed out stopping %s", unit_description(u));
break;
case JOB_DONE:
agent_open();
}
-static const char *ansi_highlight(bool b) {
+static const char *ansi_highlight_red(bool b) {
if (!on_tty())
return "";
- return b ? ANSI_HIGHLIGHT_ON : ANSI_HIGHLIGHT_OFF;
+ return b ? ANSI_HIGHLIGHT_RED_ON : ANSI_HIGHLIGHT_OFF;
}
static const char *ansi_highlight_green(bool b) {
n_shown++;
if (streq(u->load_state, "error")) {
- on_loaded = ansi_highlight(true);
- off_loaded = ansi_highlight(false);
+ on_loaded = ansi_highlight_red(true);
+ off_loaded = ansi_highlight_red(false);
} else
on_loaded = off_loaded = "";
if (streq(u->active_state, "failed")) {
- on_active = ansi_highlight(true);
- off_active = ansi_highlight(false);
+ on_active = ansi_highlight_red(true);
+ off_active = ansi_highlight_red(false);
} else
on_active = off_active = "";
if (u->state == UNIT_FILE_MASKED ||
u->state == UNIT_FILE_MASKED_RUNTIME ||
u->state == UNIT_FILE_DISABLED) {
- on = ansi_highlight(true);
- off = ansi_highlight(false);
+ on = ansi_highlight_red(true);
+ off = ansi_highlight_red(false);
} else if (u->state == UNIT_FILE_ENABLED) {
on = ansi_highlight_green(true);
off = ansi_highlight_green(false);
printf("\t Follow: unit currently follows state of %s\n", i->following);
if (streq_ptr(i->load_state, "error")) {
- on = ansi_highlight(true);
- off = ansi_highlight(false);
+ on = ansi_highlight_red(true);
+ off = ansi_highlight_red(false);
} else
on = off = "";
ss = streq_ptr(i->active_state, i->sub_state) ? NULL : i->sub_state;
if (streq_ptr(i->active_state, "failed")) {
- on = ansi_highlight(true);
- off = ansi_highlight(false);
+ on = ansi_highlight_red(true);
+ off = ansi_highlight_red(false);
} else if (streq_ptr(i->active_state, "active") || streq_ptr(i->active_state, "reloading")) {
on = ansi_highlight_green(true);
off = ansi_highlight_green(false);
good = is_clean_exit(p->code, p->status);
if (!good) {
- on = ansi_highlight(true);
- off = ansi_highlight(false);
+ on = ansi_highlight_red(true);
+ off = ansi_highlight_red(false);
} else
on = off = "";
if (i->need_daemon_reload)
printf("\n%sWarning:%s Unit file changed on disk, 'systemctl %s daemon-reload' recommended.\n",
- ansi_highlight(true),
- ansi_highlight(false),
+ ansi_highlight_red(true),
+ ansi_highlight_red(false),
arg_scope == UNIT_FILE_SYSTEM ? "--system" : "--user");
}