From 23b392166388003530fef02ac5758c91315a707b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timo=20Schl=C3=BC=C3=9Fler?= Date: Mon, 13 Jan 2020 09:26:58 +0000 Subject: [PATCH] journalctl: Correctly handle combination of --reverse and --lines (fixes #1596) --- src/journal/journalctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index c0916f372f..17565abe21 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -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); -- 2.25.1