if (!(arg_flags & SHOW_MASKED))
return 0;
- printf(ANSI_HIGHLIGHT_RED_ON "[MASKED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom);
+ printf("%s%s%s %s → %s\n",
+ ansi_highlight_red(), "[MASKED]", ansi_highlight_off(), top, bottom);
return 1;
}
if (!(arg_flags & SHOW_EQUIVALENT))
return 0;
- printf(ANSI_HIGHLIGHT_GREEN_ON "[EQUIVALENT]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom);
+ printf("%s%s%s %s → %s\n",
+ ansi_highlight_green(), "[EQUIVALENT]", ansi_highlight(), top, bottom);
return 1;
}
if (!(arg_flags & SHOW_REDIRECTED))
return 0;
- printf(ANSI_HIGHLIGHT_ON "[REDIRECTED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom);
+ printf("%s%s%s %s → %s\n",
+ ansi_highlight(), "[REDIRECTED]", ansi_highlight_off(), top, bottom);
return 1;
}
if (!(arg_flags & SHOW_OVERRIDDEN))
return 0;
- printf(ANSI_HIGHLIGHT_ON "[OVERRIDDEN]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom);
+ printf("%s%s%s %s → %s\n",
+ ansi_highlight(), "[OVERRIDDEN]", ansi_highlight_off(), top, bottom);
return 1;
}
if (!(arg_flags & SHOW_EXTENDED))
return 0;
- printf(ANSI_HIGHLIGHT_ON "[EXTENDED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom);
+ printf("%s%s%s %s → %s\n",
+ ansi_highlight(), "[EXTENDED]", ansi_highlight_off(), top, bottom);
return 1;
}
}
#endif
-static const char *ansi_highlight(bool b) {
-
- if (!on_tty())
- return "";
-
- return b ? ANSI_HIGHLIGHT_ON : ANSI_HIGHLIGHT_OFF;
-}
-
-static const char *ansi_highlight_red(bool b) {
-
- if (!on_tty())
- return "";
-
- return b ? ANSI_HIGHLIGHT_RED_ON : ANSI_HIGHLIGHT_OFF;
-}
-
-static const char *ansi_highlight_green(bool b) {
-
- if (!on_tty())
- return "";
-
- return b ? ANSI_HIGHLIGHT_GREEN_ON : ANSI_HIGHLIGHT_OFF;
-}
-
static int translate_bus_error_to_exit_status(int r, const DBusError *error) {
assert(error);
if (streq(u->load_state, "error") ||
streq(u->load_state, "not-found")) {
- on_loaded = on = ansi_highlight_red(true);
- off_loaded = off = ansi_highlight_red(false);
+ on_loaded = on = ansi_highlight_red();
+ off_loaded = off = ansi_highlight_off();
} else
on_loaded = off_loaded = "";
if (streq(u->active_state, "failed")) {
- on_active = on = ansi_highlight_red(true);
- off_active = off = ansi_highlight_red(false);
+ on_active = on = ansi_highlight_red();
+ off_active = off = ansi_highlight_off();
} else
on_active = off_active = "";
if (job_count)
printf("JOB = Pending job for the unit.\n");
puts("");
- on = ansi_highlight(true);
- off = ansi_highlight(false);
+ on = ansi_highlight();
+ off = ansi_highlight_off();
} else {
- on = ansi_highlight_red(true);
- off = ansi_highlight_red(false);
+ on = ansi_highlight_red();
+ off = ansi_highlight_off();
}
if (arg_all)
printf("\n");
}
- on = ansi_highlight(true);
- off = ansi_highlight(false);
+ on = ansi_highlight();
+ off = ansi_highlight_off();
if (!arg_no_legend)
printf("\n");
} else {
- on = ansi_highlight_red(true);
- off = ansi_highlight_red(false);
+ on = ansi_highlight_red();
+ off = ansi_highlight_off();
}
if (!arg_no_legend) {
u->state == UNIT_FILE_MASKED_RUNTIME ||
u->state == UNIT_FILE_DISABLED ||
u->state == UNIT_FILE_INVALID) {
- on = ansi_highlight_red(true);
- off = ansi_highlight_red(false);
+ on = ansi_highlight_red();
+ off = ansi_highlight_off();
} else if (u->state == UNIT_FILE_ENABLED) {
- on = ansi_highlight_green(true);
- off = ansi_highlight_green(false);
+ on = ansi_highlight_green();
+ off = ansi_highlight_off();
} else
on = off = "";
assert(n == 0 || jobs);
if (n == 0) {
- on = ansi_highlight_green(true);
- off = ansi_highlight_green(false);
+ on = ansi_highlight_green();
+ off = ansi_highlight_off();
printf("%sNo jobs running.%s\n", on, off);
return;
_cleanup_free_ char *e = NULL;
if (streq(j->state, "running")) {
- on = ansi_highlight(true);
- off = ansi_highlight(false);
+ on = ansi_highlight();
+ off = ansi_highlight_off();
} else
on = off = "";
}
}
- on = ansi_highlight(true);
- off = ansi_highlight(false);
+ on = ansi_highlight();
+ off = ansi_highlight_off();
if (on_tty())
printf("\n%s%zu jobs listed%s.\n", on, n, off);
printf(" Follow: unit currently follows state of %s\n", i->following);
if (streq_ptr(i->load_state, "error")) {
- on = ansi_highlight_red(true);
- off = ansi_highlight_red(false);
+ on = ansi_highlight_red();
+ off = ansi_highlight_off();
} 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_red(true);
- off = ansi_highlight_red(false);
+ on = ansi_highlight_red();
+ off = ansi_highlight_off();
} else if (streq_ptr(i->active_state, "active") || streq_ptr(i->active_state, "reloading")) {
- on = ansi_highlight_green(true);
- off = ansi_highlight_green(false);
+ on = ansi_highlight_green();
+ off = ansi_highlight_off();
} else
on = off = "";
good = is_clean_exit_lsb(p->code, p->status, NULL);
if (!good) {
- on = ansi_highlight_red(true);
- off = ansi_highlight_red(false);
+ on = ansi_highlight_red();
+ off = ansi_highlight_off();
} else
on = off = "";
if (i->need_daemon_reload)
printf("\n%sWarning:%s Unit file changed on disk, 'systemctl %sdaemon-reload' recommended.\n",
- ansi_highlight_red(true),
- ansi_highlight_red(false),
+ ansi_highlight_red(),
+ ansi_highlight_off(),
arg_scope == UNIT_FILE_SYSTEM ? "" : "--user ");
}