tree-wide: unify how we pick OS pretty name to display

This commit is contained in:
Lennart Poettering
2023-01-24 15:32:42 +01:00
parent 31778abf95
commit 02b7005e38
7 changed files with 29 additions and 8 deletions
+3 -2
View File
@@ -97,7 +97,7 @@ static bool press_any_key(void) {
}
static void print_welcome(void) {
_cleanup_free_ char *pretty_name = NULL, *ansi_color = NULL;
_cleanup_free_ char *pretty_name = NULL, *os_name = NULL, *ansi_color = NULL;
static bool done = false;
const char *pn, *ac;
int r;
@@ -111,12 +111,13 @@ static void print_welcome(void) {
r = parse_os_release(
arg_root,
"PRETTY_NAME", &pretty_name,
"NAME", &os_name,
"ANSI_COLOR", &ansi_color);
if (r < 0)
log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
"Failed to read os-release file, ignoring: %m");
pn = isempty(pretty_name) ? "Linux" : pretty_name;
pn = os_release_pretty_name(pretty_name, os_name);
ac = isempty(ansi_color) ? "0" : ansi_color;
if (colors_enabled())