Ephemeral status lines do not end with a newline and they expect to be
overwritten by the next printed status line.
case JOB_FAILED:
unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON "FAILED" ANSI_HIGHLIGHT_OFF, format);
case JOB_FAILED:
unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON "FAILED" ANSI_HIGHLIGHT_OFF, format);
- manager_status_printf(u->manager, NULL, "See 'systemctl status %s' for details.", u->id);
+ manager_status_printf(u->manager, false, NULL, "See 'systemctl status %s' for details.", u->id);
break;
case JOB_DEPENDENCY:
break;
case JOB_DEPENDENCY:
return plymouth_running();
}
return plymouth_running();
}
-void manager_status_printf(Manager *m, const char *status, const char *format, ...) {
+void manager_status_printf(Manager *m, bool ephemeral, const char *status, const char *format, ...) {
va_list ap;
if (!manager_get_show_status(m))
va_list ap;
if (!manager_get_show_status(m))
return;
va_start(ap, format);
return;
va_start(ap, format);
- status_vprintf(status, true, format, ap);
+ status_vprintf(status, true, ephemeral, format, ap);
void manager_recheck_journal(Manager *m);
void manager_set_show_status(Manager *m, bool b);
void manager_recheck_journal(Manager *m);
void manager_set_show_status(Manager *m, bool b);
-void manager_status_printf(Manager *m, const char *status, const char *format, ...);
+void manager_status_printf(Manager *m, bool ephemeral, const char *status, const char *format, ...);
void watch_init(Watch *w);
void watch_init(Watch *w);
-int status_vprintf(const char *status, bool ellipse, const char *format, va_list ap) {
+int status_vprintf(const char *status, bool ellipse, bool ephemeral, const char *format, va_list ap) {
static const char status_indent[] = " "; /* "[" STATUS "] " */
_cleanup_free_ char *s = NULL;
_cleanup_close_ int fd = -1;
static const char status_indent[] = " "; /* "[" STATUS "] " */
_cleanup_free_ char *s = NULL;
_cleanup_close_ int fd = -1;
+ static bool prev_ephemeral;
+ if (prev_ephemeral)
+ IOVEC_SET_STRING(iovec[n++], "\r" ANSI_ERASE_TO_END_OF_LINE);
+ prev_ephemeral = ephemeral;
+
if (status) {
if (!isempty(status)) {
IOVEC_SET_STRING(iovec[n++], "[");
if (status) {
if (!isempty(status)) {
IOVEC_SET_STRING(iovec[n++], "[");
}
IOVEC_SET_STRING(iovec[n++], s);
}
IOVEC_SET_STRING(iovec[n++], s);
- IOVEC_SET_STRING(iovec[n++], "\n");
+ if (!ephemeral)
+ IOVEC_SET_STRING(iovec[n++], "\n");
if (writev(fd, iovec, n) < 0)
return -errno;
if (writev(fd, iovec, n) < 0)
return -errno;
-int status_printf(const char *status, bool ellipse, const char *format, ...) {
+int status_printf(const char *status, bool ellipse, bool ephemeral, const char *format, ...) {
va_list ap;
int r;
assert(format);
va_start(ap, format);
va_list ap;
int r;
assert(format);
va_start(ap, format);
- r = status_vprintf(status, ellipse, format, ap);
+ r = status_vprintf(status, ellipse, ephemeral, format, ap);
#define ANSI_HIGHLIGHT_GREEN_ON "\x1B[1;32m"
#define ANSI_HIGHLIGHT_YELLOW_ON "\x1B[1;33m"
#define ANSI_HIGHLIGHT_OFF "\x1B[0m"
#define ANSI_HIGHLIGHT_GREEN_ON "\x1B[1;32m"
#define ANSI_HIGHLIGHT_YELLOW_ON "\x1B[1;33m"
#define ANSI_HIGHLIGHT_OFF "\x1B[0m"
+#define ANSI_ERASE_TO_END_OF_LINE "\x1B[K"
size_t page_size(void);
#define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
size_t page_size(void);
#define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
cpu_set_t* cpu_set_malloc(unsigned *ncpus);
cpu_set_t* cpu_set_malloc(unsigned *ncpus);
-int status_vprintf(const char *status, bool ellipse, const char *format, va_list ap);
-int status_printf(const char *status, bool ellipse, const char *format, ...);
+int status_vprintf(const char *status, bool ellipse, bool ephemeral, const char *format, va_list ap);
+int status_printf(const char *status, bool ellipse, bool ephemeral, const char *format, ...);
int status_welcome(void);
int fd_columns(int fd);
int status_welcome(void);
int fd_columns(int fd);