richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
923a60
From 8290b73eeb8da4f8f0076f3bb7e23990af734de0 Mon Sep 17 00:00:00 2001
923a60
From: Lennart Poettering <lennart@poettering.net>
923a60
Date: Fri, 24 Jul 2015 02:10:32 +0200
923a60
Subject: [PATCH] journalctl: properly detect empty journal files
923a60
923a60
When we encounter a journal file with exactly zero entries, print a nice
923a60
message and exit, and don't print a weird error message.
923a60
923a60
Cherry-picked from: 02ab86c732576a71179ce12e97d44c289833236d
923a60
Related: #1350232
923a60
---
923a60
 src/journal/journalctl.c | 6 ++++++
923a60
 1 file changed, 6 insertions(+)
923a60
923a60
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
923a60
index 6948ed689d..904aae99ed 100644
923a60
--- a/src/journal/journalctl.c
923a60
+++ b/src/journal/journalctl.c
923a60
@@ -2141,6 +2141,12 @@ int main(int argc, char *argv[]) {
923a60
                 return EXIT_FAILURE;
923a60
         }
923a60
 
923a60
+        if (r == 0) {
923a60
+                printf("-- No entries --\n");
923a60
+                return EXIT_SUCCESS;
923a60
+        }
923a60
+
923a60
+
923a60
         if (!arg_follow)
923a60
                 pager_open_if_enabled();
923a60