]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: add auto-paging
authorLennart Poettering <lennart@poettering.net>
Fri, 22 Jun 2018 18:03:49 +0000 (20:03 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 8 Oct 2018 19:40:44 +0000 (21:40 +0200)
src/boot/bootctl.c

index 3bd9db4ff89c40365288a0edf6941afd4cb10e2e..58945be542cc39b7b1286313581c004580ddc284 100644 (file)
@@ -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;
 }