]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: honor --show-cursor in more sitatuations 5930/head
authorLars Karlitski <lars@karlitski.net>
Thu, 11 May 2017 20:39:23 +0000 (22:39 +0200)
committerLars Karlitski <lars@karlitski.net>
Thu, 11 May 2017 20:49:20 +0000 (22:49 +0200)
Try to honor --show-cursor in more situations by never terminating early
when we didn't read any logs.

In particular, sd_journal_previous_skip() now returns 0 when it didn't
actually skip anything (for example with --lines=0), which resulted in
--show-cursor not working anymore.

src/journal/journalctl.c

index f990ac930355508389bd9c2ee9e76540b5840bb2..698a5a9dc85f273a2981a030fcc024f39cab7035 100644 (file)
@@ -2365,20 +2365,13 @@ int main(int argc, char *argv[]) {
                 log_error_errno(r, "Failed to iterate through journal: %m");
                 goto finish;
         }
-        if (r == 0) {
-                if (arg_follow)
-                        need_seek = true;
-                else {
-                        if (!arg_quiet)
-                                printf("-- No entries --\n");
-                        goto finish;
-                }
-        }
+        if (r == 0)
+                need_seek = true;
 
         if (!arg_follow)
                 pager_open(arg_no_pager, arg_pager_end);
 
-        if (!arg_quiet) {
+        if (!arg_quiet && (arg_lines != 0 || arg_follow)) {
                 usec_t start, end;
                 char start_buf[FORMAT_TIMESTAMP_MAX], end_buf[FORMAT_TIMESTAMP_MAX];
 
@@ -2474,6 +2467,9 @@ int main(int argc, char *argv[]) {
                 }
 
                 if (!arg_follow) {
+                        if (n_shown == 0 && !arg_quiet)
+                                printf("-- No entries --\n");
+
                         if (arg_show_cursor) {
                                 _cleanup_free_ char *cursor = NULL;