]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: do not show an empty () for ESP partition
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 21 Jan 2026 12:24:24 +0000 (21:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 13 Feb 2026 07:11:33 +0000 (16:11 +0900)
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.

src/bootctl/bootctl-status.c

index 2109e45d3484618c45f4fd58c04cf0aed2da921c..18742bdc439f01b11d8ccd30a8798bfbaab2fa36 100644 (file)
@@ -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);