From 9dae4c8a26d31d151cf1d09df6f8a21d34de8946 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 15 Jun 2019 16:37:55 +0200 Subject: [PATCH] bootctl: fix display of options with embedeed newlines I have an .efi image with embedded newlinews. Now I don't even remember if it was created for testing or by accident, but it doesn't really matter. We should display such files correctly. (This isn't a problem with normal BLS entries, because input is split into lines so newlines are consumed.) --- src/boot/bootctl.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index e7ba8b4..2f195f1 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -25,6 +25,7 @@ #include "copy.h" #include "dirent-util.h" #include "efivars.h" +#include "escape.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" @@ -377,13 +378,24 @@ static int boot_entry_show(const BootEntry *e, bool show_as_default) { *s, &status); if (!strv_isempty(e->options)) { - _cleanup_free_ char *t; + _cleanup_free_ char *t = NULL, *t2 = NULL; + _cleanup_strv_free_ char **ts = NULL; t = strv_join(e->options, " "); if (!t) return log_oom(); - printf(" options: %s\n", t); + + ts = strv_split_newlines(t); + if (!ts) + return log_oom(); + + t2 = strv_join(ts, "\n "); + if (!t2) + return log_oom(); + + + printf(" options: %s\n", t2); } if (e->device_tree) boot_entry_file_list("devicetree", e->root, e->device_tree, &status); -- 2.7.4