From: Yu Watanabe Date: Wed, 21 Jan 2026 12:24:24 +0000 (+0900) Subject: bootctl: do not show an empty () for ESP partition X-Git-Tag: v260-rc1~7^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9bc1336abd76de206641f81a6c4fef0820f4edaa;p=thirdparty%2Fsystemd.git bootctl: do not show an empty () for ESP partition Before: ``` $ run0 systemd-nspawn -xD / --private-network --bind=/sys/firmware/efi/efivars --bind=/boot -- build/bootctl --variables=yes --no-pager (snip) Boot Loader Entry Locations: ESP: /boot () config: /boot//loader/loader.conf XBOOTLDR: /boot ($BOOT) token: fedora (snip) ``` After: ``` run0 systemd-nspawn -xD / --private-network --bind=/sys/firmware/efi/efivars --bind=/boot -- build/bootctl --variables=yes --no-pager (snip) Boot Loader Entry Locations: ESP: /boot config: /boot//loader/loader.conf XBOOTLDR: /boot ($BOOT) token: fedora (snip) ``` This also moves spurious position of new line in each output. --- diff --git a/src/bootctl/bootctl-status.c b/src/bootctl/bootctl-status.c index 2109e45d348..18742bdc439 100644 --- a/src/bootctl/bootctl-status.c +++ b/src/bootctl/bootctl-status.c @@ -38,38 +38,51 @@ static int status_entries( printf("%sBoot Loader Entry Locations:%s\n", ansi_underline(), ansi_normal()); - printf(" ESP: %s (", esp_path); - if (!sd_id128_is_null(esp_partition_uuid)) - printf("/dev/disk/by-partuuid/" SD_ID128_UUID_FORMAT_STR "", + bool need_paren = false; + printf(" ESP: %s", esp_path); + if (!sd_id128_is_null(esp_partition_uuid)) { + printf(" (/dev/disk/by-partuuid/" SD_ID128_UUID_FORMAT_STR "", SD_ID128_FORMAT_VAL(esp_partition_uuid)); - if (!xbootldr_path) + need_paren = true; + } + if (!xbootldr_path) { + if (!need_paren) { + fputs(" (", stdout); + need_paren = true; + } else + fputs(", ", stdout); + /* ESP is $BOOT if XBOOTLDR not present. */ - printf(", %s$BOOT%s", ansi_green(), ansi_normal()); - printf(")"); + printf("%s$BOOT%s", ansi_green(), ansi_normal()); + } + if (need_paren) + putchar(')'); + putchar('\n'); if (config->loader_conf_status != 0) { assert(esp_path); - printf("\n config: %s%s/%s%s", + printf(" config: %s%s/%s%s", ansi_grey(), esp_path, ansi_normal(), "/loader/loader.conf"); if (config->loader_conf_status < 0) printf(": %s%s%s", config->loader_conf_status == -ENOENT ? ansi_grey() : ansi_highlight_yellow(), STRERROR(config->loader_conf_status), ansi_normal()); + putchar('\n'); } if (xbootldr_path) { - printf("\n XBOOTLDR: %s (", xbootldr_path); + printf(" XBOOTLDR: %s (", xbootldr_path); if (!sd_id128_is_null(xbootldr_partition_uuid)) printf("/dev/disk/by-partuuid/" SD_ID128_UUID_FORMAT_STR ", ", SD_ID128_FORMAT_VAL(xbootldr_partition_uuid)); /* XBOOTLDR is always $BOOT if present. */ - printf("%s$BOOT%s)", ansi_green(), ansi_normal()); + printf("%s$BOOT%s)\n", ansi_green(), ansi_normal()); } if (settle_entry_token() >= 0) - printf("\n token: %s", arg_entry_token); - printf("\n\n"); + printf(" token: %s\n", arg_entry_token); + putchar('\n'); if (config->default_entry < 0) printf("%zu entries, no entry could be determined as default.\n", config->n_entries);