From 57db6f18d4fefb83a8c7807e6fe30410c2aca378 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 22 Jun 2018 20:03:49 +0200 Subject: [PATCH] bootctl: add auto-paging --- src/boot/bootctl.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 3bd9db4..58945be 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -29,6 +29,7 @@ #include "fileio.h" #include "fs-util.h" #include "locale-util.h" +#include "pager.h" #include "parse-util.h" #include "rm-rf.h" #include "stat-util.h" @@ -43,6 +44,7 @@ static char *arg_path = NULL; static bool arg_print_path = false; static bool arg_touch_variables = true; +static bool arg_no_pager = false; static int acquire_esp( bool unprivileged_mode, @@ -855,6 +857,7 @@ static int help(int argc, char *argv[], void *userdata) { " --path=PATH Path to the EFI System Partition (ESP)\n" " -p --print-path Print path to the EFI partition\n" " --no-variables Don't touch EFI variables\n" + " --no-pager Do not pipe output into a pager\n" "\nCommands:\n" " status Show status of installed systemd-boot and EFI variables\n" " list List boot entries\n" @@ -874,6 +877,7 @@ static int parse_argv(int argc, char *argv[]) { ARG_PATH = 0x100, ARG_VERSION, ARG_NO_VARIABLES, + ARG_NO_PAGER, }; static const struct option options[] = { @@ -882,6 +886,7 @@ static int parse_argv(int argc, char *argv[]) { { "path", required_argument, NULL, ARG_PATH }, { "print-path", no_argument, NULL, 'p' }, { "no-variables", no_argument, NULL, ARG_NO_VARIABLES }, + { "no-pager", no_argument, NULL, ARG_NO_PAGER }, {} }; @@ -914,6 +919,10 @@ static int parse_argv(int argc, char *argv[]) { arg_touch_variables = false; break; + case ARG_NO_PAGER: + arg_no_pager = true; + break; + case '?': return -EINVAL; @@ -953,6 +962,8 @@ static int verb_status(int argc, char *argv[], void *userdata) { r = 0; /* If we couldn't determine the path, then don't consider that a problem from here on, just show what we * can show */ + (void) pager_open(arg_no_pager, false); + if (is_efi_boot()) { _cleanup_free_ char *fw_type = NULL, *fw_info = NULL, *loader = NULL, *loader_path = NULL, *stub = NULL; sd_id128_t loader_part_uuid = SD_ID128_NULL; @@ -1035,6 +1046,8 @@ static int verb_list(int argc, char *argv[], void *userdata) { else { size_t n; + (void) pager_open(arg_no_pager, false); + printf("Boot Loader Entries:\n"); for (n = 0; n < config.n_entries; n++) { @@ -1157,6 +1170,8 @@ int main(int argc, char *argv[]) { r = bootctl_main(argc, argv); finish: + pager_close(); free(arg_path); + return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; } -- 2.7.4