]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: Correctly handle combination of --reverse and --lines (fixes #1596)
authorTimo Schlüßler <schluessler@krause.de>
Mon, 13 Jan 2020 09:26:58 +0000 (09:26 +0000)
committerLennart Poettering <lennart@poettering.net>
Mon, 13 Jan 2020 16:35:06 +0000 (17:35 +0100)
src/journal/journalctl.c

index c0916f372f3503fb65aff708ccd3fa8a3e54292f..17565abe2128b53d9a9e8578289fc88ea54c8c9c 100644 (file)
@@ -2428,23 +2428,23 @@ int main(int argc, char *argv[]) {
                 }
                 r = sd_journal_previous(j);
 
-        } else if (arg_lines >= 0) {
+        } else if (arg_reverse) {
                 r = sd_journal_seek_tail(j);
                 if (r < 0) {
                         log_error_errno(r, "Failed to seek to tail: %m");
                         goto finish;
                 }
 
-                r = sd_journal_previous_skip(j, arg_lines);
+                r = sd_journal_previous(j);
 
-        } else if (arg_reverse) {
+        } else if (arg_lines >= 0) {
                 r = sd_journal_seek_tail(j);
                 if (r < 0) {
                         log_error_errno(r, "Failed to seek to tail: %m");
                         goto finish;
                 }
 
-                r = sd_journal_previous(j);
+                r = sd_journal_previous_skip(j, arg_lines);
 
         } else {
                 r = sd_journal_seek_head(j);