From 16044277e9b2810c04970276fda3fb052b742727 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 Jul 2024 17:56:01 +0200 Subject: [PATCH] pid1: use $COLUMNS info in status_vprintf() This way, we can work around the fact that "struct winsize" for /dev/console might not be initialized the moment we open the device. --- src/core/show-status.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/show-status.c b/src/core/show-status.c index 57ad4db30b5..7c7c10f9636 100644 --- a/src/core/show-status.c +++ b/src/core/show-status.c @@ -72,8 +72,14 @@ int status_vprintf(const char *status, ShowStatusFlags flags, const char *format int c; c = fd_columns(fd); - if (c <= 0) - c = 80; + if (c <= 0) { + const char *env = getenv("COLUMNS"); + if (env) + (void) safe_atoi(env, &c); + + if (c <= 0) + c = 80; + } sl = status ? strlen(status_indent) : 0; -- 2.47.3