chiark / gitweb /
journal: pipe journalctl help output into a pager
authorDjalal Harouni <tixxdz@opendz.org>
Wed, 11 Dec 2013 23:22:48 +0000 (00:22 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 12 Dec 2013 03:26:55 +0000 (22:26 -0500)
journalctl help output might run off the screen, so be consistent
as other systemd tools do and pipe it into a pager.

src/journal/journalctl.c

index 5d12c2b..cc338e0 100644 (file)
@@ -114,8 +114,18 @@ typedef struct boot_id_t {
         uint64_t last;
 } boot_id_t;
 
+static void pager_open_if_enabled(void) {
+
+        if (arg_no_pager)
+                return;
+
+        pager_open(arg_pager_end);
+}
+
 static int help(void) {
 
+        pager_open_if_enabled();
+
         printf("%s [OPTIONS...] [MATCHES...]\n\n"
                "Query the journal.\n\n"
                "Flags:\n"
@@ -1647,8 +1657,8 @@ int main(int argc, char *argv[]) {
                 return EXIT_FAILURE;
         }
 
-        if (!arg_no_pager && !arg_follow)
-                pager_open(arg_pager_end);
+        if (!arg_follow)
+                pager_open_if_enabled();
 
         if (!arg_quiet) {
                 usec_t start, end;