systemd/0164-journal-pipe-journalct...

46 lines
1.3 KiB
Diff

From 59f2f4cfd399275c3da061212fc25636ee72367f Mon Sep 17 00:00:00 2001
From: Djalal Harouni <tixxdz@opendz.org>
Date: Thu, 12 Dec 2013 00:22:48 +0100
Subject: [PATCH] journal: pipe journalctl help output into a pager
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 | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index a5c4779..71e28b0 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -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"
@@ -1635,8 +1645,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;